Отчеты Java / cucumber не производят отчеты с использованием masterthought - PullRequest
0 голосов
/ 20 февраля 2019

Я пытался интегрировать masterthought maven - отчетность по огурцам, чтобы я мог создавать симпатичные отчеты о Дженкинсе, как рекламируется.Я следовал инструкциям по настройке на различных сайтах, в том числе на постах damienfremont.com, но моя реализация не дает никаких отчетов.Аналогичные сообщения в StackOverflow не дали ответа.

CucumberTestRunner.java

@RunWith(Cucumber.class)
@CucumberOptions(
  glue = "xxx.yyy.zzz.cucumber",
  features = "src/test/resources/features",
  snippets = SnippetType.CAMELCASE,
  tags = {"@aaa", "@bbb"},
  plugin = {"json:target/cucumber.json", "html:target/site/cucumber-pretty"}
  )
public class CucumberTestRunner {}

pom.xml

  <dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>4.2.0</version>
  </dependency>

  <dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>4.2.0</version>
  </dependency>

  <dependency>
    <groupId>net.masterthought</groupId>
    <artifactId>cucumber-reporting</artifactId>
    <version>4.4.0</version>
  </dependency>

  Other dependencies - Spring, database, logging, etc

<dependencies>

<build>
  <plugins>

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.7.0</version>
      <configuration>
        <source>1.8</source>
        <target>1.8</target>
      </configuration>
    </plugin>

    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>exec-maven-plugin</artifactId>
      <version>1.5.0</version>      
      <executions>
        <execution>
          <phase>integration-test</phase>
          <goals>
            <goal>java</goal>
          </goals>
          <configuration>
            <classpathScope>test</classpathScope>
            <mainClass>cucumber.api.cli.Main</mainClass>
            <arguments>
              <argument>--glue</argument><argument>xxx.yyy.zzz.cucumber</argument>
              <argument>--snippets</argument><argument>camelcase</argument>
              <argument>--plugin</argument><argument>html:target/cucumber.html</argument>
              <argument>src/test/resources</argument>  <!-- features location -->
            </arguments>
          </configuration>
        <\execution>
      </executions>
    </plugin>

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>2.21.0</version>
      <configuration>
        <testFailureIgnore>true</testFailureIgnore>
      </configuration>
    </plugin>

    <plugin>
      <groupId>net.masterthought</groupId>
      <artifactId>maven--cucumber-reporting</artifactId>
      <version>4.4.0</version>      
      <executions>
        <execution>
          <id>execution</id>
          <phase>verify</phase>
          <goals>
            <goal>generate</goal>
          </goals>
          <configuration>
            <projectName>ExecuteReporting</projectname>
            <outputDirectory>${project.build.directory}/site/cucumber-reports</outputDirectory>
            <cucumberOutput>${project.build.directory}/cucumber-jason</cucumberOutput>
            <checkBuildResult>cucumber.api.cli.Main</checkBuildResult>
          </configuration>
        <\execution>
      </executions>
    </plugin>      

  </plugins>
</build>

Результаты: запуск CucumberTestRunner.java из intelliJ создаетtarget / cucumber.json и target / site / cucumber-pretty / index.html и др.

запуск mvn verify -Dcucumber.options = "- tags @aaa --tags @bbb" создает целевой объект / cucumber.html / index.html и др. (как указано в pom)

Итак, создаются родные верные отчеты, но я не получаю выдачу masterthought.

Когда я запускаю mvnпри сборке через Jenkins с установленным плагином cucumber-reports.hfi я получаю сообщение "net.masterthought.cucumber.ValidationException: файл без отчета был добавлен!"Это имеет смысл, поскольку задание mvn не создает отчеты. Пароль

Я рассмотрел другие проблемы со StackOverflow и не вижу, в чем проблема с моим кодом.Любая помощь с благодарностью.

Ответы [ 2 ]

0 голосов
/ 22 февраля 2019

Проблема отсортирована: в pom.xml, exec-maven-plugin, мне нужен аргумент плагина для json: $ {project.build.directory} / где-то / для / reports

Требуются пушистые отчеты Дженкинсафайлы JSON.Также необходимо убедиться, что каталоги, указанные в конфигурации отчетов Jenkins Cucumber, соответствуют каталогам, указанным в файле pom.xml.

Не требуется подключаемый модуль net.masterthought.

0 голосов
/ 21 февраля 2019

Я тоже получаю ту же ошибку.Затем я использовал приведенный ниже код вместо использования плагина pom.xml «net.masterthought».Это сработало и сгенерировало отчет.Но я использовал TestNG.Итак, вам придется проверить, работает ли он с JUnit, используя аннотацию @After.

    @AfterSuite
    public void generateReport() {
    File reportOutputDirectory = new File("target"); //
    List<String> jsonFiles = new ArrayList<String>();
    jsonFiles.add("target/cucumber.json");
    String projectName = "Your Sample Project Name";
    String buildNumber = "1.0";

    Configuration configuration = new Configuration(reportOutputDirectory, 
    projectName);

    configuration.setRunWithJenkins(true);
    configuration.setBuildNumber(buildNumber);

    ReportBuilder reportBuilder = new ReportBuilder(jsonFiles, configuration);
    reportBuilder.generateReports();
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...