Можно ли использовать allure с testNG и JUnit в одном проекте?
У меня есть старый проект, который использует JUnit, и я хочу переместить проект в testNG, но мы должны поддерживать старые тесты в JUnit.
Я использую testNG - 6.8, JUnit - 4.12, allure - 1.5.4, Maven.
Я создаю в pom.xml 2 профиля: 'testNG' и 'default' - для запуска тестов с использованием JUnit.
pom.xml
<properties>
<allure.version>1.5.4</allure.version>
<aspectj.version>1.8.9</aspectj.version>
</properties>
<profiles>
<profile>
<id>default</id>
<properties>
<junit>true</junit>
<listener>ru.yandex.qatools.allure.junit.AllureRunListener</listener>
</properties>
</profile>
<profile>
<id>testNG</id>
<properties>
<junit>false</junit>
</properties>
<dependencies>
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-testng-adaptor</artifactId>
<version>${allure.version}</version>
</dependency>
</dependencies>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-junit-adaptor</artifactId>
<version>${allure.version}</version>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-maven-plugin</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
-Xmx${heap_size}m
</argLine>
<properties>
<property>
<name>listener</name>
<value>${listener}</value>
</property>
<property>
<name>junit</name>
<value>${junit}</value>
</property>
</properties>
<reportsDirectory>${project.basedir}/target</reportsDirectory>
<excludes>
<exclude>${excludeTest}</exclude>
</excludes>
<failIfNoTests>false</failIfNoTests>
<runOrder>alphabetical</runOrder>
</configuration>
</plugin>
</plugins>
</build>
В результате: тесты testNG работают нормально, очаровательный отчет генерируется, но когда я запускаю тесты jUnit, у меня возникает следующая проблема, когда jenkins пытается создать отчет:
Listener ru.yandex.qatools.allure.junit.AllureRunListener@4bc222e must be one of ITestListener, ISuiteListener, IReporter, IAnnotationTransformer, IMethodInterceptor or IInvokedMethodListener
15:43:41 Usage: <main class> [options] The XML suite files to run
15:43:41 Options:
15:43:41 -configfailurepolicy Configuration failure policy (skip or
15:43:41 continue)
15:43:41 -d Output directory
15:43:41 -dataproviderthreadcount Number of threads to use when running
15:43:41 data providers
15:43:41 -excludegroups Comma-separated list of group names to
15:43:41 exclude
15:43:41 -groups Comma-separated list of group names to be
15:43:41 run
15:43:41 -junit JUnit mode
15:43:41 Default: false
15:43:41 -listener List of .class files or list of class
15:43:41 names implementing ITestListener or
15:43:41 ISuiteListener
15:43:41 -methods Comma separated of test methods
15:43:41 Default: []
15:43:41 -methodselectors List of .class files or list of class
15:43:41 names implementing IMethodSelector
15:43:41 -mixed Mixed mode - autodetect the type of
15:43:41 current test and run it with appropriate runner
15:43:41 Default: false
15:43:41 -objectfactory List of .class files or list of class
15:43:41 names implementing ITestRunnerFactory
15:43:41 -parallel Parallel mode (methods, tests or classes)
15:43:41 -port The port
15:43:41 -reporter Extended configuration for custom report
15:43:41 listener
15:43:41 -suitename Default name of test suite, if not
15:43:41 specified in suite definition file or source code
15:43:41 -suitethreadpoolsize Size of the thread pool to use to run
15:43:41 suites
15:43:41 Default: 1
15:43:41 -testclass The list of test classes
15:43:41 -testjar A jar file containing the tests
15:43:41 -testname Default name of test, if not specified in
15:43:41 suitedefinition file or source code
15:43:41 -testnames The list of test names to run
15:43:41 -testrunfactory, -testRunFactory The factory used to create tests
15:43:41 -threadcount Number of threads to use when running
15:43:41 tests in parallel
15:43:41 -usedefaultlisteners Whether to use the default listeners
15:43:41 Default: true
15:43:41 -log, -verbose Level of verbosity
15:43:41 -xmlpathinjar The full path to the xml file inside the
15:43:41 jar file (only valid if -testjar was
15:43:41 specified)
15:43:41 Default: testng.xml
15:43:41
15:43:41
15:43:41 Results :
15:43:41
15:43:41 Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
15:43:41
15:43:41 [INFO] ------------------------------------------------------------------------
15:43:41 [INFO] Reactor Summary:
15:43:41 [INFO]
15:43:41 [INFO] beans .............................................. SUCCESS [ 13.854 s]
15:43:41 [INFO] core ............................................... SUCCESS [ 7.125 s]
15:43:41 [INFO] tests .............................................. FAILURE [ 29.277 s]
15:43:41 [INFO] API automation ..................................... SKIPPED
15:43:41 [INFO] ------------------------------------------------------------------------
15:43:41 [INFO] BUILD FAILURE
15:43:41 [INFO] ------------------------------------------------------------------------
15:43:41 [INFO] Total time: 50.396 s
15:43:41 [INFO] Finished at: 2019-03-26T12:43:41+00:00
15:43:42 [INFO] Final Memory: 73M/1479M
15:43:42 [INFO] ------------------------------------------------------------------------
15:43:42 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project tests: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
Если я удаляю из pom.xml testng:
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
</dependency>
Тесты JUnit работают, но невозможно использовать testNG.
Можете ли вы помочь использовать отчеты об очаровании для testNG и JUnit в одном проекте?