TestNG中日志记录和测试报告(九)
在自动化测试中,我们更加的希望失败的测试用例的我们可以得到一些跟踪的信息,这样方便我们定位问题和解决问题,
当然最大化的可以快速提升解决问题的思路。仅仅是日子是不够的,我们期望执行结束后,能够输出完整的测试报告,这样
的目的是我们可以把测试报告呈现给对应的leader以及在反馈整体产品质量的时候有一份依据,我们期望这些过程都是自动
化的,而不是人为的去统计以及参与。所以,本文章主要围绕两个点来,一是个TestNG测试框架中日志的记录,另外就是
TestNG测试框架中测试报告的输出以及呈现。
使用TestNG生成报表有两个方法,具体如下:
-
Listeners:要实现listeren类,就得继续实现org. testng.ITestListener接口,当测试开始,执行成功,失败,忽略都会进
行通知。
- Reporters:要实现reporting类,就得必须实现org. testng.IReporter接口。当整个测试套件执行结束后,调用这些类里面
的方法,调用包含整个测试运行信息的对象在调用时传递给此类。
应根据生成报告方式和时间的情况使用每个报告。例如,如果要在执行结束时生成自定义 HTML 报表,则应在编写扩展时实现
IReporter 接口。但是,如果您想要在运行时更新文件,并且必须在执行测试时打印消息,那么我们应该使用 ITestListener 接
口。
下面我们使用ITestListener实现log的编写部分,被测试的测试类的源码信息:
package test.logger; import org.testng.Assert; import org.testng.annotations.Test; public class SimpleTest { @Test public void testSuccess() { Assert.assertTrue(true); } @Test public void testFailure() { Assert.assertFalse(true); } @Test(enabled = false) public void testSkipped() { } }
继承ITestListeren的接口的类源码,具体如下:
package test.logger; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import org.testng.ITest; import org.testng.ITestContext; import org.testng.ITestListener; import org.testng.ITestResult; public class CustomerLogger implements ITestListener { @Override public void onTestStart(ITestResult result) { System.out.println("测试方法开始前 "+result.getName()+" 开始时间"+this.getCurrentTime()); } public String getCurrentTime() { DateFormat dateFormat=new SimpleDateFormat("HH:mm:ss:SSS"); Date dt=new Date(); return dateFormat.format(dt); } @Override public void onTestSuccess(ITestResult result) { System.out.println("执行成功的测试方法 "+result.getName()+" 执行时间"+this.getCurrentTime()); } @Override public void onTestFailure(ITestResult result) { System.out.println("执行失败的测试方法 "+result.getName()+" 执行时间"+this.getCurrentTime()); } @Override public void onTestSkipped(ITestResult result) { System.out.println("执行忽略的测试方法 "+result.getName()+" 执行时间"+this.getCurrentTime()); } @Override public void onTestFailedButWithinSuccessPercentage(ITestResult result) { } @Override public void onStart(ITestContext context) { System.out.println("执行测试套件内容 "+context.getName()+" 执行时间"+this.getCurrentTime()); } @Override public void onFinish(ITestContext context) { System.out.println("执行完成的测试套件 "+context.getName()+" 执行时间"+this.getCurrentTime()); } }
完善testng.xml的配置文件,新增listeners,完善后的testng.xml配置文件为:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <!--<suite name="UnitSuite">--> <suite name="Simple Logger Suite"> <listeners> <listener class-name="test.logger.CustomerLogger"></listener> </listeners> <test name="Simple Logger Test"> <classes> <class name="test.logger.SimpleTest"></class> </classes> </test> </suite>
选择testng.xml的文件进行执行,执行后的结果信息为:
[INFO] Scanning for projects... [INFO] [INFO] -------------------------< org.example:ngApp >-------------------------- [INFO] Building ngApp 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ ngApp --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ ngApp --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ ngApp --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory /Applications/code/workSpace/ngApp/src/test/resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ ngApp --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 31 source files to /Applications/code/workSpace/ngApp/target/test-classes [INFO] [INFO] --- maven-surefire-plugin:2.14.1:test (default-test) @ ngApp --- [INFO] Surefire report directory: /Applications/code/workSpace/ngApp/target/surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running TestSuite 执行测试套件内容 Simple Logger Test 执行时间10:19:27:129 测试方法开始前 testFailure 开始时间10:19:27:137 执行失败的测试方法 testFailure 执行时间10:19:27:147 测试方法开始前 testSuccess 开始时间10:19:27:147 执行成功的测试方法 testSuccess 执行时间10:19:27:148 执行完成的测试套件 Simple Logger Test 执行时间10:19:27:166 Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.247 sec <<< FAILURE! testFailure(test.logger.SimpleTest) Time elapsed: 0.011 sec <<< FAILURE! java.lang.AssertionError: expected [false] but found [true] at org.testng.Assert.fail(Assert.java:94) at org.testng.Assert.failNotEquals(Assert.java:496) at org.testng.Assert.assertFalse(Assert.java:63) at org.testng.Assert.assertFalse(Assert.java:73) at test.logger.SimpleTest.testFailure(SimpleTest.java:17) Results : Failed tests: SimpleTest.testFailure:17 expected [false] but found [true] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.671 s [INFO] Finished at: 2021-01-16T10:19:27+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.14.1:test (default-test) on project ngApp: There are test failures. [ERROR] [ERROR] Please refer to /Applications/code/workSpace/ngApp/target/surefire-reports for the individual test results. [ERROR] -> [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
在如上的信息中,可以看到执行后打印出对应的输出的信息
下面我们来看测试报告的部分,我们继续完善代码,本次我们需要继承IReporter的接口来完善如下的信息,完善后的测试类的源码为:
package test.logger; import org.testng.Assert; import org.testng.annotations.Test; public class SimpleTest { @Test public void testSuccess() { Assert.assertTrue(true); } @Test public void testFailure() { Assert.assertFalse(true); } @Test(dependsOnMethods = "testFailure") public void testSkipped() { Assert.assertTrue(true); } }
继承IReporter的类的源码为:
package test.logger; import java.util.List; import java.util.Map; import org.testng.IReporter; import org.testng.ISuite; import org.testng.ISuiteResult; import org.testng.ITestContext; import org.testng.xml.XmlSuite; public class CustomerReporter implements IReporter { @Override public void generateReport(List<XmlSuite> xmlSuites,List<ISuite> suites,String outputDirector) { for(ISuite suite:suites) { String suiteName=suite.getName(); Map<String, ISuiteResult> suiteResults=suite.getResults(); for(ISuiteResult sr:suiteResults.values()) { ITestContext tc=sr.getTestContext(); System.out.println("通过的测试套件 "+suiteName+" is "+tc.getPassedTests().getAllResults().size()); System.out.println("失败的测试套件 "+suiteName+" is "+tc.getFailedTests().getAllResults().size()); System.out.println("忽略的测试套件 "+suiteName+" is "+tc.getSkippedTests().getAllResults().size()); } } } }
完善后的testng.xml的配置文件的内容为:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <!--<suite name="UnitSuite">--> <suite name="Simple Logger Suite"> <listeners> <!-- <listener class-name="test.logger.CustomerLogger"></listener>--> <listener class-name="test.logger.CustomerReporter"></listener> </listeners> <test name="Simple Logger Test"> <classes> <class name="test.logger.SimpleTest"></class> </classes> </test> </suite>
再次执行,执行后的结果信息为:
[INFO] Scanning for projects... [INFO] [INFO] -------------------------< org.example:ngApp >-------------------------- [INFO] Building ngApp 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ ngApp --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ ngApp --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ ngApp --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory /Applications/code/workSpace/ngApp/src/test/resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ ngApp --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 31 source files to /Applications/code/workSpace/ngApp/target/test-classes [INFO] [INFO] --- maven-surefire-plugin:2.14.1:test (default-test) @ ngApp --- [INFO] Surefire report directory: /Applications/code/workSpace/ngApp/target/surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running TestSuite 执行测试套件内容 Simple Logger Test 执行时间10:19:27:129 测试方法开始前 testFailure 开始时间10:19:27:137 执行失败的测试方法 testFailure 执行时间10:19:27:147 测试方法开始前 testSuccess 开始时间10:19:27:147 执行成功的测试方法 testSuccess 执行时间10:19:27:148 执行完成的测试套件 Simple Logger Test 执行时间10:19:27:166 Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.247 sec <<< FAILURE! testFailure(test.logger.SimpleTest) Time elapsed: 0.011 sec <<< FAILURE! java.lang.AssertionError: expected [false] but found [true] at org.testng.Assert.fail(Assert.java:94) at org.testng.Assert.failNotEquals(Assert.java:496) at org.testng.Assert.assertFalse(Assert.java:63) at org.testng.Assert.assertFalse(Assert.java:73) at test.logger.SimpleTest.testFailure(SimpleTest.java:17) Results : Failed tests: SimpleTest.testFailure:17 expected [false] but found [true] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.671 s [INFO] Finished at: 2021-01-16T10:19:27+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.14.1:test (default-test) on project ngApp: There are test failures. [ERROR] [ERROR] Please refer to /Applications/code/workSpace/ngApp/target/surefire-reports for the individual test results. [ERROR] -> [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 localhost:ngApp liwangping$ mvn test [INFO] Scanning for projects... [INFO] [INFO] -------------------------< org.example:ngApp >-------------------------- [INFO] Building ngApp 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ ngApp --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ ngApp --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ ngApp --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory /Applications/code/workSpace/ngApp/src/test/resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ ngApp --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 32 source files to /Applications/code/workSpace/ngApp/target/test-classes [INFO] [INFO] --- maven-surefire-plugin:2.14.1:test (default-test) @ ngApp --- [INFO] Surefire report directory: /Applications/code/workSpace/ngApp/target/surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running TestSuite 通过的测试套件 Simple Logger Suite is 1 失败的测试套件 Simple Logger Suite is 1 忽略的测试套件 Simple Logger Suite is 1 Tests run: 3, Failures: 1, Errors: 0, Skipped: 1, Time elapsed: 0.249 sec <<< FAILURE! testFailure(test.logger.SimpleTest) Time elapsed: 0.009 sec <<< FAILURE! java.lang.AssertionError: expected [false] but found [true] at org.testng.Assert.fail(Assert.java:94) at org.testng.Assert.failNotEquals(Assert.java:496) at org.testng.Assert.assertFalse(Assert.java:63) at org.testng.Assert.assertFalse(Assert.java:73) at test.logger.SimpleTest.testFailure(SimpleTest.java:17) Results : Failed tests: SimpleTest.testFailure:17 expected [false] but found [true] Tests run: 3, Failures: 1, Errors: 0, Skipped: 1 [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.948 s [INFO] Finished at: 2021-01-16T10:35:46+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.14.1:test (default-test) on project ngApp: There are test failures. [ERROR] [ERROR] Please refer to /Applications/code/workSpace/ngApp/target/surefire-reports for the individual test results. [ERROR] -> [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/MojoFailureExceptionkan
从输出的信息可以看到,很清晰的打印出测试报告的信息。
当然这样的测试报告更多的应用于我们自己的调试,我们更多希望的是测试报告它是基于HTML的测试报告,这样看起来更加的让人舒服点。
默认情况下,报表在名为 testout 的文件夹下生成,可以通过配置它更改为任何其他文件夹。这些报告由特定于 TestNG 的某些 HTML 和 XML
报告组成。 执行后,具体见如下,打开index.html的文件,就能够看到本次执行的测试报告的信息,如下所示:

我们完善testng.xml的配置文件,执行所有的测试用例,完善后的内容为:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <!--<suite name="UnitSuite">--> <suite name="Simple Logger Suite" thread-count="1"> <listeners> <listener class-name="test.logger.CustomerLogger"></listener> <listener class-name="test.logger.CustomerReporter"></listener> </listeners> <test name="Run All Tests"> <packages> <package name="test.*"></package> </packages> </test> </suite>
执行后,查看index.html的测试报告,内容具体如下:

概要信息里面能够看出总共多少测试用例,以及成功多少,失败多少,和忽略执行多少,其他信息在这里我就不详细的介绍了。坦白说
如上的测试报告并不是很友好的,下面我们使用Allure的测试报告,想系统的了解Allure的框架,可以看我Pytest测试技术栈介绍的内容。
我们在pom.xml文件内容新增引入Allure,具体内容如下:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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>org.example</groupId> <artifactId>ngApp</artifactId> <version>1.0-SNAPSHOT</version> <properties> <!--编译编码--> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <aspectj.version>1.8.10</aspectj.version> </properties> <dependencies> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.10</version> <scope>compile</scope> </dependency> <!--WebDriver的测试框架--> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>3.141.59</version> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-server</artifactId> <version>3.141.59</version> </dependency> <!--引入Allure的框架--> <dependency> <groupId>io.qameta.allure</groupId> <artifactId>allure-testng</artifactId> <version>2.0-BETA14</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.14.1</version> <configuration> <!--testng配置文件名称--> <suiteXmlFiles> <suiteXmlFile>testng.xml</suiteXmlFile> </suiteXmlFiles> <threadCount>1</threadCount> <parallel>tests</parallel> <!--测试失败后忽略继续执行--> <testFailureIgnore>true</testFailureIgnore> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> </configuration> </plugin> <!--Alure的c jian插件--> <!-- <plugin>--> <!-- <groupId>org.apache.maven.plugins</groupId>--> <!-- <artifactId>maven-surefire-plugin</artifactId>--> <!-- <version>2.20</version>--> <!-- <configuration>--> <!-- <argLine>--> <!-- -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"--> <!-- </argLine>--> <!-- </configuration>--> <!-- <dependencies>--> <!-- <dependency>--> <!-- <groupId>org.aspectj</groupId>--> <!-- <artifactId>aspectjweaver</artifactId>--> <!-- <version>1.9.2</version>--> <!-- </dependency>--> <!-- </dependencies>--> <!-- </plugin>--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.20</version> <configuration> <argLine> -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar" </argLine> <!--生成allure-result的目录--> <systemProperties> <property> <name>allure.results.directory</name> <value>./target/allure-results</value> </property> </systemProperties> </configuration> <dependencies> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>${aspectj.version}</version> </dependency> </dependencies> </plugin> </plugins> </build> </project>
testng.xml的配置文件内容为:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <!--<suite name="UnitSuite">--> <suite name="Simple Logger Suite" thread-count="1"> <listeners> <listener class-name="test.logger.CustomerLogger"></listener> <listener class-name="test.logger.CustomerReporter"></listener> </listeners> <test name="Run All Tests"> <classes> <class name="test.parallelism.SimpleUiTwo"></class> </classes> </test> </suite>
执行命令:mvn test后,输出信息如下:
[INFO] Scanning for projects... [WARNING] [WARNING] Some problems were encountered while building the effective model for org.example:ngApp:jar:1.0-SNAPSHOT [WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-surefire-plugin @ line 96, column 21 [WARNING] [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. [WARNING] [WARNING] For this reason, future Maven versions might no longer support building such malformed projects. [WARNING] [INFO] [INFO] -------------------------< org.example:ngApp >-------------------------- [INFO] Building ngApp 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ ngApp --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ ngApp --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ ngApp --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /Applications/code/workSpace/ngApp/src/test/resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ ngApp --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.20:test (default-test) @ ngApp --- [INFO] [INFO] ------------------------------------------------------- [INFO] T E S T S [INFO] ------------------------------------------------------- [INFO] Running TestSuite SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 执行测试套件内容 Run All Tests 执行时间11:52:36:178 Starting ChromeDriver 87.0.4280.88 (89e2380a3e36c3464b5dd1302349b1382549290d-refs/branch-heads/4280@{#1761}) on port 29529 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully. 一月 16, 2021 11:52:38 上午 org.openqa.selenium.remote.ProtocolHandshake createSession 信息: Detected dialect: W3C 测试方法开始前 test_baidu_title 开始时间11:52:39:299 执行成功的测试方法 test_baidu_title 执行时间11:52:39:347 Starting ChromeDriver 87.0.4280.88 (89e2380a3e36c3464b5dd1302349b1382549290d-refs/branch-heads/4280@{#1761}) on port 28641 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully. 一月 16, 2021 11:52:40 上午 org.openqa.selenium.remote.ProtocolHandshake createSession 信息: Detected dialect: W3C 测试方法开始前 test_baidu_url 开始时间11:52:41:404 执行成功的测试方法 test_baidu_url 执行时间11:52:41:412 执行完成的测试套件 Run All Tests 执行时间11:52:41:513 通过的测试套件 Simple Logger Suite is 2 失败的测试套件 Simple Logger Suite is 0 忽略的测试套件 Simple Logger Suite is 0 [INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.036 s - in TestSuite [INFO] [INFO] Results: [INFO] [INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 7.790 s [INFO] Finished at: 2021-01-16T11:52:41+08:00 [INFO] ------------------------------------------------------------------------
再次执行命令:allure serve target/allure-results,就能够看到结果报告信息了,如下所示:

这样就可以看到很完美的自动化测试报告了,我们也可以整合到CI的平台中。感谢您的阅读!

浙公网安备 33010602011771号