forked from testng-team/testng
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parameter alwaysRun=true for before-methods forces execution of those…
… methods Closes testng-team#1622
- Loading branch information
1 parent
b543b4f
commit d2aa85c
Showing
6 changed files
with
82 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/test/java/test/configuration/github1622/Issue1622Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package test.configuration.github1622; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.testng.ITestNGListener; | ||
import org.testng.TestNG; | ||
import org.testng.annotations.DataProvider; | ||
import org.testng.annotations.Test; | ||
import org.testng.xml.XmlSuite; | ||
import test.InvokedMethodNameListener; | ||
import test.SimpleBaseTest; | ||
|
||
public class Issue1622Test extends SimpleBaseTest { | ||
@Test(dataProvider = "dp") | ||
public void testWithoutGroups(XmlSuite.FailurePolicy failurePolicy, String ...expected) { | ||
TestNG testNG = create(TestClassWithNoGroups.class); | ||
testNG.setConfigFailurePolicy(failurePolicy); | ||
InvokedMethodNameListener listener = new InvokedMethodNameListener(); | ||
testNG.addListener((ITestNGListener) listener); | ||
testNG.run(); | ||
Assertions.assertThat(listener.getInvokedMethodNames()).contains(expected); | ||
} | ||
|
||
@DataProvider(name = "dp") | ||
public Object[][] getData() { | ||
return new Object[][] { | ||
{XmlSuite.FailurePolicy.SKIP, "failedBeforeSuite"}, | ||
{XmlSuite.FailurePolicy.CONTINUE, "failedBeforeSuite", "beforeTest", "beforeClass", "beforeMethod"} | ||
}; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/test/java/test/configuration/github1622/TestClassWithNoGroups.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package test.configuration.github1622; | ||
|
||
import org.testng.ITestNGListener; | ||
import org.testng.TestNG; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.BeforeSuite; | ||
import org.testng.annotations.BeforeTest; | ||
import org.testng.annotations.DataProvider; | ||
import org.testng.annotations.Test; | ||
import org.testng.xml.XmlSuite; | ||
import test.InvokedMethodNameListener; | ||
import test.SimpleBaseTest; | ||
|
||
public class TestClassWithNoGroups { | ||
|
||
@BeforeSuite | ||
public void failedBeforeSuite() { | ||
throw new RuntimeException(); | ||
} | ||
|
||
@BeforeTest(alwaysRun = true) | ||
public void beforeTest() { | ||
throw new RuntimeException(); | ||
} | ||
|
||
@BeforeClass(alwaysRun = true) | ||
public void beforeClass() { | ||
throw new RuntimeException(); | ||
} | ||
|
||
@BeforeMethod(alwaysRun = true) | ||
public void beforeMethod() { | ||
throw new RuntimeException(); | ||
} | ||
|
||
@Test | ||
public void testMethod() { | ||
System.out.println("I'm testMethod"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters