セレン テストに TestNG を使用しています。私のラップトップで複数回実行する必要がある「Create Firm」というテストがあります。
そこで、このために「CreateFirm」というクラスを作成しました。さまざまな企業のデータが Excel スプレッドシートに格納されています。
さまざまな時期に、さまざまな会社のセットを作成する必要があります。これらは、コンピューター名を保持する Excel スプレッドシートの列を使用して制御します。
@Factory を使用して「CreateFirm」クラスを作成します。このクラスには、会社を作成するための @Test メソッドが 1 つあります。
Excelスプレッドシートで、Firm1、Firm2、Firm3、Firm4を同じ順序でラップトップに割り当てた場合、@FactoryはFirm4、Firm3、Firm1、Firm2のようにランダムな順序でそれらを作成します
私の質問は、 @Factory を取得して、必要な順序でテスト インスタンスを作成する方法です。
私の @Factory メソッドは
      @Factory
  public Object[] runCreateFirm()
  {
        //This is where I get the list of test cases assigned to my laptop
        this.test_id_list=get_test_ids_for_test_run("Create Firm (class approach).xls", "Global");      
        Object[] result = new Object[this.test_id_list.size()];
        int index=0 ;
        for (String firm_id: this.test_id_list)
        {
            //This is where I get all the test data from the Excel spreadsheet
            HashMap<String,String> test_data_row=this.get_row_from_excel("Create Firm (class approach).xls", "Global", "test_case_id", firm_id);
            System.out.println("Inside Firm Factory ,index="+index +", test case id="+ test_data_row.get("test_case_id"));
            //CreateFirm is the class which will use the data and do all the UI actions to create a Firm
            result[index]=new CreateFirm(test_data_row);
            index++;
        }
        return result;
  }
XMLは
    <?xml version="1.0" encoding="UTF-8"?>
<suite name="CreateFirm Suite">
  <test name="Create Firm Test"  order-by-instances="false">
    <classes>
      <class name="regressionTests.factory.CreateFirmFactory"/>
    </classes>
  </test>
</suite>