I have this Factory class
public class SimpleTestFactory{
@Factory
public Object[] factoryMethod(){
return new Object[] { new SmokeSuite("carrier1"),new SmokeSuite("carrier2") };
}}
Now I have this test class - I am using a FactoryHelper class to "save" the value of carrier so i can get it later and reuse it.
package com.xxx.xxx.mobile;
public class SmokeSuite extends MobileTestBase {
private String carrier;
public SmokeSuite(String carrier){
this.carrier=carrier;
FactoryHelper.setTier(carrier);
logger.info("------------ Running for "+carrier);
}
// Commented out setup and teardown to save space
@Test
public void test1() throws Exception {
System.out.println("-------------------------");
System.out.println(FactoryHelper.getTier());
System.out.println(carrier);
System.out.println("-------------------------");
}}
This is my output
[INFO ] 2019-06-20 00:25:27.637 [main] MobileTestBase - ------------ Running for carrier1
[INFO ] 2019-06-20 00:25:27.640 [main] MobileTestBase - ------------ Running for carrier2
-------------------------
carrier2
carrier1
-------------------------
-------------------------
carrier2
carrier2
-------------------------
So it seems like the carrier value is being picked up and printed in the constructor only but not in the actual test. But the value of carrier is printed as expected. My expected result is
-------------------------
carrier1
carrier1
-------------------------
-------------------------
carrier2
carrier2
-------------------------
Any help would be super helpful . thank you
Aucun commentaire:
Enregistrer un commentaire