В настоящее время я пишу интеграционный тест, где мне нужно проверить некоторые условия до того, как мои тесты могут быть выполнены.DependsOnGroups Исключение с исключением циклических зависимостей
public class TheClassWhichContainsIT {
@Test(dependsOnGroups = { "init" })
public void thisIsTheFirstTest() {
System.out.printf("Test");
}
@Test(groups = "init")
public void checkIfWeAreOnWindows() {
throw new SkipException("Not on windows");
}
}
Приведенный выше пример работает, как ожидалось, если SkipException брошено, чем тесты будут помечены как пропустили и не удалось, как мне это нравится.
Так на основе Cedric Beust's blog я хочу, чтобы реорганизовать свои интеграционные тесты в следующем:
@Test(dependsOnGroups = { "init" })
public class TheClassWhichContainsIT extends IntegrationTestBase {
public void thisIsTheFirstTest() {
System.out.printf("Test");
}
}
@Test(groups = "init")
public class IntegrationTestBase {
public void checkIfWeAreOnWindows() {
throw new SkipException("ignore");
}
}
Но если я пытаюсь запустить свои тесты я получил следующее:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.
16:test (default-test) on project testngtest: Execution default-test of goal org
.apache.maven.plugins:maven-surefire-plugin:2.16:test failed: There was an error
in the forked process
[ERROR] org.testng.TestNGException:
[ERROR] The following methods have cyclic dependencies:
[ERROR] TheClassWhichContainsTest.thisIsTheFirstTest()[pri:0, instance:de.akdb.k
[email protected]]
[ERROR]
[ERROR] at org.testng.internal.Graph.topologicalSort(Graph.java:148)
[ERROR] at org.testng.internal.MethodHelper.topologicalSort(MethodHelper.java:26
1)
[ERROR] at org.testng.internal.MethodHelper.sortMethods(MethodHelper.java:317)
[ERROR] at org.testng.internal.MethodHelper.collectAndOrderMethods(MethodHelper.
java:59)
[ERROR] at org.testng.TestRunner.initMethods(TestRunner.java:481)
[ERROR] at org.testng.TestRunner.init(TestRunner.java:235)
[ERROR] at org.testng.TestRunner.init(TestRunner.java:205)
[ERROR] at org.testng.TestRunner.<init>(TestRunner.java:153)
[ERROR] at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRu
nner.java:522)
[ERROR] at org.testng.SuiteRunner.init(SuiteRunner.java:157)
[ERROR] at org.testng.SuiteRunner.<init>(SuiteRunner.java:111)
[ERROR] at org.testng.TestNG.createSuiteRunner(TestNG.java:1299)
[ERROR] at org.testng.TestNG.createSuiteRunners(TestNG.java:1286)
[ERROR] at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
[ERROR] at org.testng.TestNG.run(TestNG.java:1057)
[ERROR] at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.ja
va:91)
[ERROR] at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeSing
leClass(TestNGDirectoryTestSuite.java:128)
[ERROR] at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(Tes
tNGDirectoryTestSuite.java:112)
[ERROR] at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider
.java:113)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameCla
ssLoader(ForkedBooter.java:200)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(Fork
edBooter.java:153)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:
103)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutio
nException
Вы нашли решение? –