TFS构建有两个主要步骤:
的pom.xml
<profiles>
<profile>
<id>test</id>
<properties></properties>
<build>
<testResources>
<testResource>
<directory>${project.basedir}/td</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<argLine>
- javaagent:"${project.basedir}/lib/aspectjweaver-${aspectj.version}.jar"
</argLine>
<suiteXmlFiles>
<suiteXmlFile>${project.basedir}/src/test/resources/suites/mno/SUITE.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<outputDirectory>${project.basedir}/target/newsite</outputDirectory>
<alwaysGenerateSurefireReport>true</alwaysGenerateSurefireReport>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-maven</artifactId>
<version>2.8</version>
<configuration>
<propertiesFilePath>${project.basedir}/src/main/resources/allure.properties</propertiesFilePath>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
allure.properties
allure.results.directory=target/allure-results
在TFS上执行测试后,Allure2报告不会生成异常:
2018-06-12T08:00:59.8942816Z ##[section]Starting: Generate Allure Report
2018-06-12T08:00:59.8945657Z ==============================================================================
2018-06-12T08:00:59.8945772Z Task : Generate Allure Report
2018-06-12T08:00:59.8945857Z Description : Generates Allure report based on the test results
2018-06-12T08:00:59.8945939Z Version : 1.0.0
2018-06-12T08:00:59.8946025Z Author : Molecula
2018-06-12T08:00:59.8946112Z Help : [More Information](https://github.com/allure-framework/allure-core/wiki)
2018-06-12T08:00:59.8946207Z ==============================================================================
2018-06-12T08:01:00.1039436Z [command]C:\Program Files\nodejs\node.exe D:\a\_tasks\AllureGenerate_5c975f9d-1c3a-469f-b7c2-8907bf3eacfb\1.0.0\node_modules\allure-commandline\bin\allure generate --output D:\a\1\s\allure-report\20180612.2 D:\a\1\s\allure-results
2018-06-12T08:01:01.5322339Z Command aborted due to exception {}.
2018-06-12T08:01:01.5322862Z ru.yandex.qatools.allure.command.AllureCommandException: Report directory <D:\a\1\s\allure-results> not found.
2018-06-12T08:01:01.5323182Z at ru.yandex.qatools.allure.command.ReportGenerate.validateResultsDirectories(ReportGenerate.java:59)
2018-06-12T08:01:01.5323397Z at ru.yandex.qatools.allure.command.ReportGenerate.runUnsafe(ReportGenerate.java:46)
2018-06-12T08:01:01.5323593Z at ru.yandex.qatools.allure.command.AbstractCommand.run(AbstractCommand.java:52)
2018-06-12T08:01:01.5323798Z at ru.yandex.qatools.allure.CommandLine.main(CommandLine.java:46)
2018-06-12T08:01:01.5325236Z ru.yandex.qatools.allure.command.AllureCommandException: Report directory <D:\a\1\s\allure-results> not found.
2018-06-12T08:01:01.5325437Z at ru.yandex.qatools.allure.command.ReportGenerate.validateResultsDirectories(ReportGenerate.java:59)
2018-06-12T08:01:01.5325598Z at ru.yandex.qatools.allure.command.ReportGenerate.runUnsafe(ReportGenerate.java:46)
2018-06-12T08:01:01.5325771Z at ru.yandex.qatools.allure.command.AbstractCommand.run(AbstractCommand.java:52)
2018-06-12T08:01:01.5325928Z at ru.yandex.qatools.allure.CommandLine.main(CommandLine.java:46)
2018-06-12T08:01:01.5326036Z
2018-06-12T08:01:01.5429506Z ##[error]Unable to process command '##vso[results.publish type=Allure;mergeResults=true;publishRunAttachments=true;resultFiles=D:\a\1\s\allure-report\20180612.2;]' successfully. Please reference documentation (http://go.microsoft.com/fwlink/?LinkId=817296)
2018-06-12T08:01:01.5442151Z ##[error]Unknown Test Runner.
2018-06-12T08:01:01.5451505Z ##[section]Finishing: Generate Allure Report
那么,我做错了什么?或者你可能还有另一种产生Allure2报告的方法吗?