栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

mvn clean test中文乱码,导致IDEA生成allure测试报告中文乱码

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

mvn clean test中文乱码,导致IDEA生成allure测试报告中文乱码

案例代码
import io.qameta.allure.*;
import io.qameta.allure.junit4.DisplayName;
import io.qameta.allure.model.Status;
import io.qameta.allure.model.StepResult;
import org.junit.Test;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;



public class TestAllure {

    @Test
    @DisplayName("测试用例名称")
    @Description("测试用例描述")
    @link("https://www.baidu.com")
    @Issue("bug编号110")
    @Severity(SeverityLevel.MINOR)
    public void demo01(){
        login();
        login();
        StepResult stepResult = new StepResult();
        stepResult.setStatus(Status.FAILED);
        stepResult.setName("测试用例类名");
        Allure.getLifecycle().startStep("细化",stepResult);
        Allure.getLifecycle().stopStep();
        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 for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ceshi002 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ ceshi002 ---
[INFO] Deleting E:源码ceshi002target
[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]
[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:源码ceshi002srctestresources
[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 1 source file to E:源码ceshi002targettest-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 http://www.slf4j.org/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:源码ceshi002targetsurefire-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] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
IDEA生成allure测试报告中文乱码
E:源码ceshi002>allure serve allure-results
Generating report to temp directory...
Report successfully generated to C:UsersshenyfAppDataLocalTemp4653105515360773502allure-report
Starting web server...
2021-09-27 13:47:10.490:INFO::main: Logging initialized @7678ms to org.eclipse.jetty.util.log.StdErrLog
Server started at . Press  to exit

解决办法:


pom.xml文件:

	
        1.8.10
        UTF-8
    

问题解决后显示正常:
E:源码ceshi002>mvn clean test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ceshi002 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ ceshi002 ---
[INFO] Deleting E:源码ceshi002target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ ceshi002 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[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 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:源码ceshi002srctestresources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ ceshi002 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to E:源码ceshi002targettest-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 http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Running TestAllure
登录
登录
[ERROR] Tests run: 3, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 2.16 s <<< FAILURE! - in TestAllure
[ERROR] demo01(TestAllure)  Time elapsed: 1.767 s  <<< FAILURE!
java.lang.AssertionError:

Expected: <2>
     but: was <1>
        at TestAllure.demo01(TestAllure.java:37)

[ERROR] demo3(TestAllure)  Time elapsed: 0.006 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: 9.854 s
[INFO] Finished at: 2021-09-27T13:49:50+08:00
[INFO] Final Memory: 16M/165M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.20:test (default-test) on project ceshi002: Ther
e are test failures.
[ERROR]
[ERROR] Please refer to E:源码ceshi002targetsurefire-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] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

E:源码ceshi002>allure serve allure-results
Generating report to temp directory...
Report successfully generated to C:UsersshenyfAppDataLocalTemp4653105515360773502allure-report
Starting web server...
2021-09-27 13:47:10.490:INFO::main: Logging initialized @7678ms to org.eclipse.jetty.util.log.StdErrLog
Server started at . Press  to exit

最终pom.xml文件


    4.0.0

    com.cn.test
    ceshi002
    1.0-SNAPSHOT


    
        1.8.10
        UTF-8
    

    
        
            org.hamcrest
            hamcrest
            2.2
        
        
            io.qameta.allure
            allure-junit4
            2.15.0
            test
        
        
            junit
            junit
            4.12
        
    

    
        
            
                org.apache.maven.plugins
                maven-surefire-plugin
                2.20
                
                    false
                    
                        -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                    
                    
                        
                            listener
                            io.qameta.allure.junit4.AllureJunit4
                        
                    
                
                
                    
                        org.aspectj
                        aspectjweaver
                        ${aspectj.version}
                    
                
            
        
    

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/270748.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号