mvncleantest中⽂乱码,导致IDEA⽣成allure测试报告中⽂乱码案例代码
import*;
import DisplayName;
import Status;
import StepResult;
import Test;
import FileInputStream;
import FileNotFoundException;
import static CoreMatchers.*;
import static Assert.assertThat;
/**
* TODO
*
* @author TaoGe
* @version 1.0
* @date 2021/9/27 11:09
*/
public class TestAllure {
@Test
@DisplayName("测试⽤例名称")
@Description("测试⽤例描述")
@Link("www.baidu")
@Issue("bug编号110")
@Severity(SeverityLevel.MINOR)
public void demo01(){
login();
login();
StepResult stepResult =new StepResult();
stepResult.setStatus(Status.FAILED);
stepResult.setName("测试⽤例类名");
assertThat(1,equalTo(2));
}
@Step("login步骤")
public void login(){
try{
Allure.addAttachment("图⽚","image/png",new FileInputStream("E:\\icon\\a.png"),".png");
}catch(FileNotFoundException e){
e.printStackTrace();
}
System.out.println("登录");
}
@Test
public void demo2(){
assertThat(2,equalTo(2));
}
@Test
public void demo3(){
assertThat(3,equalTo(4));
}
}
mvn clean test中⽂乱码
E:\源码\ceshi002>mvn clean test
[INFO] Scanning
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ceshi002 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ ceshi002 ---
[INFO] Deleting E:\源码\ceshi002\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ ceshi002 ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource
[INFO]
idea debug
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ ceshi002 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ ceshi002 ---[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory E:\源码\ceshi002\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ ceshi002 ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent! [INFO] Compiling 1source file to E:\源码\ceshi002\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.20:test (default-test) @ ceshi002 ---
[INFO]
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See /codes.html#StaticLoggerBinder for further details.
[INFO] Running TestAllure
鐧诲綍
鐧诲綍
[ERROR] Tests run: 3, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 1.974 s <<< FAILURE! - in TestAllure [ERROR] demo01(TestAllure)  Time elapsed: 1.627 s  <<< FAILURE!
java.lang.AssertionError:
Expected: <2>
but: was <1>
at TestAllure.demo01(TestAllure.java:37)
[ERROR] demo3(TestAllure)  Time elapsed: 0.002 s  <<< FAILURE!
java.lang.AssertionError:
Expected: <4>
but: was <3>
at TestAllure.demo3(TestAllure.java:60)
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR]  TestAllure.demo01:37
Expected: <2>
but: was <1>
[ERROR]  TestAllure.demo3:60
Expected: <4>
but: was <3>
[INFO]
[ERROR] Tests run: 3, Failures: 2, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.470 s
[INFO] Finished at: 2021-09-27T13:46:35+08:00
[INFO] Final Memory: 15M/129M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.20:test (default-test) on project ceshi002: There are test failures. [ERROR]
[ERROR] Please refer to E:\源码\ceshi002\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist)[date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[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] /confluence/display/MAVEN/MojoFailureException
IDEA⽣成allure测试报告中⽂乱码
E:\源码\ceshi002>allure serve allure-results
Generating report to
Report successfully generated to C:\Users\shenyf\AppData\Local\Temp\4653105515360773502\allure-report
Starting
2021-09-27 13:47:10.490:INFO::main: Logging initialized @7678ms lipse.jetty.util.log.StdErrLog
Server started at <169.254.188.171:57332/>. Press <Ctrl+C> to exit
解决办法:
<properties>
<aspectj.version>1.8.10</aspectj.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties>
问题解决后显⽰正常:
E:\源码\ceshi002>mvn clean test
[INFO] Scanning
[INFO]
[INFO] ------------------------------------------------------------------------

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。