2017-01-27 20 views
2

Мне нужно приложить Allure к моему тестовому проекту Cucumber (Java).Не удалось выполнить цель org.apache.maven.plugins: maven-surefire-plugin: 2.19.1: тест во время тестирования огурца

Фактически, все тесты, которые у меня есть, выполняются правильно, если я запускаю их из тестового запуска JUnit.

Если я запускаю мои тесты с командой:

mvn clean test 

В конце Maven войти я получаю:

[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 17.078 s 
[INFO] Finished at: 2017-01-27T17:11:17+03:00 
[INFO] Final Memory: 27M/322M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project web-test: Exception in provider: java.lang.NullPointerException -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[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 read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException 

Это вызывает ситуацию, когда Allure-отчеты не могут быть сформированы aftet mvn site команда.

Вот StackTrace ошибки:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project web-test: Exception in provider: java.lang.NullPointerException -> [Help 1] 
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project web-test: Exception in provider 
     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212) 
     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 
     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 
     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) 
     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) 
     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) 
     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) 
     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) 
     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) 
     at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) 
     at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863) 
     at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) 
     at org.apache.maven.cli.MavenCli.main(MavenCli.java:199) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
     at java.lang.reflect.Method.invoke(Method.java:498) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) 
Caused by: org.apache.maven.plugin.MojoFailureException: Exception in provider 
     at org.apache.maven.plugin.surefire.SurefirePlugin.assertNoException(SurefirePlugin.java:328) 
     at org.apache.maven.plugin.surefire.SurefirePlugin.handleSummary(SurefirePlugin.java:318) 
     at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:892) 
     at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:755) 
     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) 
     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207) 
     ... 20 more 
Caused by: org.apache.maven.surefire.booter.SurefireExecutionException: Exception in provider 
     at org.apache.maven.plugin.surefire.InPluginVMSurefireStarter.runSuitesInProcess(InPluginVMSurefireStarter.java:87) 
     at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1010) 
     at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:862) 
     ... 23 more 
Caused by: org.apache.maven.surefire.testset.TestSetFailedException: java.lang.NullPointerException 
     at org.apache.maven.surefire.common.junit4.JUnit4RunListener.rethrowAnyTestMechanismFailures(JUnit4RunListener.java:209) 
     at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:169) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
     at java.lang.reflect.Method.invoke(Method.java:498) 
     at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:202) 
     at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:155) 
     at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:81) 
     at org.apache.maven.plugin.surefire.InPluginVMSurefireStarter.runSuitesInProcess(InPluginVMSurefireStarter.java:82) 
     ... 25 more 
Caused by: java.lang.NullPointerException 
     at org.junit.runner.Description.createSuiteDescription(Description.java:123) 
     at ru.yandex.qatools.allure.junit.AllureRunListener.getSuiteUid(AllureRunListener.java:110) 
     at ru.yandex.qatools.allure.junit.AllureRunListener.testStarted(AllureRunListener.java:50) 
     at org.junit.runner.notification.RunNotifier$3.notifyListener(RunNotifier.java:115) 
     at org.junit.runner.notification.RunNotifier$SafeNotifier.run(RunNotifier.java:61) 
     at org.junit.runner.notification.RunNotifier.fireTestStarted(RunNotifier.java:112) 
     at org.apache.maven.surefire.common.junit4.Notifier.fireTestStarted(Notifier.java:100) 
     at org.junit.internal.runners.model.EachTestNotifier.fireTestStarted(EachTestNotifier.java:43) 
     at cucumber.runtime.junit.JUnitReporter.startExecutionUnit(JUnitReporter.java:54) 
     at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:100) 
     at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:63) 
     at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:18) 
     at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) 
     at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) 
     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) 
     at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) 
     at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) 
     at org.junit.runners.ParentRunner.run(ParentRunner.java:309) 
     at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:70) 
     at cucumber.api.junit.Cucumber.runChild(Cucumber.java:95) 
     at cucumber.api.junit.Cucumber.runChild(Cucumber.java:38) 
     at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) 
     at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) 
     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) 
     at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) 
     at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) 
     at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) 
     at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) 
     at org.junit.runners.ParentRunner.run(ParentRunner.java:309) 
     at cucumber.api.junit.Cucumber.run(Cucumber.java:100) 
     at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:367) 
     at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:274) 
     at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238) 
     at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:161) 
     ... 33 more 
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException 

А вот содержимое файла pom.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns="http://maven.apache.org/POM/4.0.0" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>m2m-selenium</groupId> 
    <artifactId>web-test</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <aspectj.version>1.7.4</aspectj.version> 
     <allure.version>1.4.23</allure.version> 
     <serverAddress>http://site</serverAddress> 
     <username>admin</username> 
     <password>admin</password> 
     <browser>chrome</browser> 
     <timeout>500</timeout> 
     <!--Selenium driver: remote or local--> 
     <seleniumDriver>local</seleniumDriver> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>org.hamcrest</groupId> 
      <artifactId>hamcrest-all</artifactId> 
      <version>1.3</version> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-api</artifactId> 
      <version>1.7.21</version> 
     </dependency> 
     <dependency> 
      <groupId>pl.pragmatists</groupId> 
      <artifactId>JUnitParams</artifactId> 
      <version>1.0.4</version> 
     </dependency> 
     <dependency> 
      <groupId>ch.qos.logback</groupId> 
      <artifactId>logback-classic</artifactId> 
      <version>1.1.7</version> 
     </dependency> 
     <dependency> 
      <groupId>ru.yandex.qatools.allure</groupId> 
      <artifactId>allure-junit-adaptor</artifactId> 
      <version>${allure.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.11</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-java</artifactId> 
      <version>3.0.1</version> 
     </dependency> 
     <dependency> 
      <groupId>info.cukes</groupId> 
      <artifactId>cucumber-java</artifactId> 
      <version>1.2.5</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>info.cukes</groupId> 
      <artifactId>cucumber-junit</artifactId> 
      <version>1.2.5</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>info.cukes</groupId> 
      <artifactId>gherkin</artifactId> 
      <version>2.12.2</version> 
     </dependency> 
     <!--NEW--> 
     <dependency> 
      <groupId>ru.yandex.qatools.allure</groupId> 
      <artifactId>allure-cucumber-jvm-adaptor</artifactId> 
      <version>1.6.1</version> 
     </dependency> 
    </dependencies> 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <version>2.19.1</version> 
       <configuration> 
        <testFailureIgnore>false</testFailureIgnore> 
        <argLine> 
         -javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar 
         -Dcucumber.options="--plugin ru.yandex.qatools.allure.cucumberjvm.AllureReporter" 
        </argLine> 
        <properties> 
         <property> 
          <encoding>${project.build.sourceEncoding}</encoding> 
          <name>listener</name> 
          <value>ru.yandex.qatools.allure.junit.AllureRunListener</value> 
         </property> 
        </properties> 
        <forkMode>never</forkMode> 
        <!-- <reuseForks>false</reuseForks>--> 
        <testFailureIgnore>true</testFailureIgnore> 
        <systemPropertyVariables> 
         <serverAddress>${serverAddress}</serverAddress> 
         <username>${username}</username> 
         <password>${password}</password> 
         <buildDirectory>${project.build.directory}</buildDirectory> 
         <browser>${browser}</browser> 
         <timeout>${timeout}</timeout> 
         <seleniumDriver>${seleniumDriver}</seleniumDriver> 
        </systemPropertyVariables> 
       </configuration> 
       <dependencies> 
        <dependency> 
         <groupId>org.aspectj</groupId> 
         <artifactId>aspectjweaver</artifactId> 
         <version>${aspectj.version}</version> 
        </dependency> 
       </dependencies> 
      </plugin> 
      <!--Needed only to show reports locally. Run jetty:run and 
      open localhost:8080 to show the report--> 
      <plugin> 
       <groupId>org.eclipse.jetty</groupId> 
       <artifactId>jetty-maven-plugin</artifactId> 
       <version>9.2.10.v20150310</version> 
       <configuration> 
        <webAppSourceDirectory>${project.build.directory}/site/allure-maven-plugin</webAppSourceDirectory> 
        <stopKey>stop</stopKey> 
        <stopPort>1234</stopPort> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
    <reporting> 
     <excludeDefaults>true</excludeDefaults> 
     <plugins> 
      <plugin> 
       <groupId>ru.yandex.qatools.allure</groupId> 
       <artifactId>allure-maven-plugin</artifactId> 
       <version>2.5</version> 
       <configuration> 
        <resultsDirectory>allure-results</resultsDirectory> 
       </configuration> 
      </plugin> 
     </plugins> 
    </reporting> 
</project> 

Не могли бы вы помочь мне с этим, пожалуйста?

ответ

1

Это потому, что вы перепутались с папками и конфигурацией. Прежде всего, удалите зависимость allure-junit-adapter. И, наконец, удалите раздел свойств из уверенной конфигурации.

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns="http://maven.apache.org/POM/4.0.0" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>m2m-selenium</groupId> 
    <artifactId>b2b-web-test</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <aspectj.version>1.7.4</aspectj.version> 
     <allure.version>1.4.23</allure.version> 
     <serverAddress>http://m2m-b2b/b2b/</serverAddress> 
     <username>admin</username> 
     <password>admin</password> 
     <browser>chrome</browser> 
     <timeout>500</timeout> 
     <!--Selenium driver: remote or local--> 
     <seleniumDriver>local</seleniumDriver> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>org.hamcrest</groupId> 
      <artifactId>hamcrest-all</artifactId> 
      <version>1.3</version> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-api</artifactId> 
      <version>1.7.21</version> 
     </dependency> 
     <dependency> 
      <groupId>pl.pragmatists</groupId> 
      <artifactId>JUnitParams</artifactId> 
      <version>1.0.4</version> 
     </dependency> 
     <dependency> 
      <groupId>ch.qos.logback</groupId> 
      <artifactId>logback-classic</artifactId> 
      <version>1.1.7</version> 
     </dependency> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.11</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-java</artifactId> 
      <version>3.0.1</version> 
     </dependency> 
     <dependency> 
      <groupId>info.cukes</groupId> 
      <artifactId>cucumber-java</artifactId> 
      <version>1.2.5</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>info.cukes</groupId> 
      <artifactId>cucumber-junit</artifactId> 
      <version>1.2.5</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>info.cukes</groupId> 
      <artifactId>gherkin</artifactId> 
      <version>2.12.2</version> 
     </dependency> 
     <!--NEW--> 
     <dependency> 
      <groupId>ru.yandex.qatools.allure</groupId> 
      <artifactId>allure-cucumber-jvm-adaptor</artifactId> 
      <version>1.6.1</version> 
     </dependency> 
    </dependencies> 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <version>2.19.1</version> 
       <configuration> 
        <testFailureIgnore>false</testFailureIgnore> 
        <argLine> 
         -javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar 
         -Dcucumber.options="--plugin ru.yandex.qatools.allure.cucumberjvm.AllureReporter" 
        </argLine> 
        <properties> 
         <property> 
          <encoding>${project.build.sourceEncoding}</encoding> 
         </property> 
        </properties> 
        <forkMode>never</forkMode> 
        <!-- <reuseForks>false</reuseForks>--> 
        <testFailureIgnore>true</testFailureIgnore> 
        <systemPropertyVariables> 
         <serverAddress>${serverAddress}</serverAddress> 
         <username>${username}</username> 
         <password>${password}</password> 
         <buildDirectory>${project.build.directory}</buildDirectory> 
         <browser>${browser}</browser> 
         <timeout>${timeout}</timeout> 
         <seleniumDriver>${seleniumDriver}</seleniumDriver> 
        </systemPropertyVariables> 
       </configuration> 
       <dependencies> 
        <dependency> 
         <groupId>org.aspectj</groupId> 
         <artifactId>aspectjweaver</artifactId> 
         <version>${aspectj.version}</version> 
        </dependency> 
       </dependencies> 
      </plugin> 
      <!--Needed only to show reports locally. Run jetty:run and 
      open localhost:8080 to show the report--> 
      <plugin> 
       <groupId>org.eclipse.jetty</groupId> 
       <artifactId>jetty-maven-plugin</artifactId> 
       <version>9.2.10.v20150310</version> 
       <configuration> 
        <webAppSourceDirectory>${project.build.directory}/site/allure-maven-plugin</webAppSourceDirectory> 
        <stopKey>stop</stopKey> 
        <stopPort>1234</stopPort> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
    <reporting> 
     <excludeDefaults>true</excludeDefaults> 
     <plugins> 
      <plugin> 
       <groupId>ru.yandex.qatools.allure</groupId> 
       <artifactId>allure-maven-plugin</artifactId> 
       <version>2.5</version> 
       <configuration> 
        <resultsDirectory>allure-results</resultsDirectory> 
       </configuration> 
      </plugin> 
     </plugins> 
    </reporting> 
</project> 
+0

Это довольно странно, чтобы удалить конфигурацию с уверенного места. Но если да, то где я должен переместить его в этом случае? – SanchelliosProg

+0

Allure-cucumber-jvm-adapter с 1.6 использует другой механизм взаимодействия. Теперь он работает как плагин cucumber-jvm вместо прослушивателя junit. Это причина, по которой вы должны удалить слушателя из конфиденциальной конфигурации. –

+0

Пожалуйста, не могли бы вы рефакторировать файл pom, который я опубликовал в описании вопроса? Я пытался сделать то, что вы рекомендовали, и оно не работает. Теперь я ge t [ERROR] Не удалось выполнить цель org.apache.maven.plugins: maven-surefire-plugin: 2.19.1: test (default-test) в проекте b2b-web-test: Выполнение по умолчанию-теста цели org .apache.maven.plugins: maven-surefire-plug in: 2.19.1: test failed: org.apache.maven.surefire.util.SurefireReflectionException: java.lang.ClassNotFoundException: ru.yandex.qatools.allure.junit. AllureRunListener -> [Помощь 1] – SanchelliosProg