• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package test.bug92;
2 
3 import java.util.Arrays;
4 
5 import org.testng.Assert;
6 import org.testng.TestNG;
7 import org.testng.annotations.Test;
8 import org.testng.xml.XmlSuite;
9 import org.testng.xml.XmlTest;
10 
11 import test.SimpleBaseTest;
12 
13 public class Bug92Test extends SimpleBaseTest {
14 
15 	@Test(description = "Fix for https://github.com/cbeust/testng/issues/92")
BeforeTestShouldRunOnce()16 	public void BeforeTestShouldRunOnce() {
17 		XmlSuite s = createXmlSuite("Bug92");
18 		XmlTest t = createXmlTest(s, "Bug92 test", TestAlpha.class.getName(),
19 				TestBravo.class.getName());
20 		s.setTests(Arrays.asList(t));
21 		TestNG tng = create();
22 		tng.setXmlSuites(Arrays.asList(s));
23 		TestBase.beforeTestCount = 0;
24 		TestBase.beforeTestAlwaysCount = 0;
25 		tng.run();
26 		Assert.assertEquals(TestBase.beforeTestCount, 1);
27 		Assert.assertEquals(TestBase.beforeTestAlwaysCount, 1);
28 	}
29 }
30