01: package test.factory;
02:
03: public class MyTest {
04: private int i;
05:
06: // in this test, our default constructor sets s to a value that will cause a failure
07: // the valid test instances should come from the factory
08: public MyTest() {
09: i = 0;
10: }
11:
12: public MyTest(int i) {
13: this .i = i;
14: }
15:
16: /**
17: * @testng.test groups="MyTest"
18: */
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: /**
26: * @testng.test dependsOnGroups="testMethodOnFactoryClass"
27: */
28: public void verifyThatTestMethodOnFactoryClassWasRun() {
29: assert FactoryInSeparateClass.wasRun() : "Test method on factory class wasn't run";
30: }
31:
32: }
|