• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package test.factory;
2 
3 import org.testng.annotations.Test;
4 
5 public class MyTest {
6   private int i;
7 
8   // in this test, our default constructor sets s to a value that will cause a failure
9   // the valid test instances should come from the factory
MyTest()10   public MyTest() {
11     i = 0;
12   }
13 
MyTest(int i)14   public MyTest(int i) {
15     this.i = i;
16   }
17 
18   @Test(groups = "MyTest")
testMethod()19   public void testMethod() {
20     FactoryInSeparateClass.addToSum(i);
21     //    assert i > 0 : "MyTest was not constructed with correct params";
22     assert (i != 0) : "My test was not created by the factory";
23   }
24 
25   @Test(dependsOnGroups = "testMethodOnFactoryClass")
verifyThatTestMethodOnFactoryClassWasRun()26   public void verifyThatTestMethodOnFactoryClassWasRun() {
27     assert FactoryInSeparateClass.wasRun() : "Test method on factory class wasn't run";
28   }
29 
30 }