AssertionError的IDEA输出中的字符编码 [英] Character encoding in IDEA output of AssertionError

查看:538
本文介绍了AssertionError的IDEA输出中的字符编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用IntelliJ IDEA 12.0.4。
有一些测试。当我使用JUnit4框架运行一个我的Assertion错误看起来像:

  java.lang.AssertionError:状态应该是:Черновик如果我使用一个TestNG,它看起来像这样: 

/ p>

  java.lang.AssertionError:状态应为:Р§РμСЂРЅРѕРІРёРєexpected [true] but found [false] 

所有其他的cyrillic输出在两个框架上都正常工作,只有断言文本不会。



项目文件编码设置为UTF-8。



更新:
例如简单的WebDriver测试。我使用TestNG和IE。

  import org.testng.Assert; 
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

import java.util.concurrent.TimeUnit;


public class SeleniumExample {

protected WebDriver driver;
protected String baseUrl;

@BeforeSuite
public void setUp()throws Exception
{

/ *本地驱动程序* /
driver = new InternetExplorerDriver ;
baseUrl =http://www.google.com;
driver.manage()。timeouts()。implicitlyWait(30,TimeUnit.SECONDS);
}

@DataProvider
public Object [] [] TestData(){
return new Object [] [] {
{Гугл} ,
};
}

@Test(description =Create_InvestProjectRequest,dataProvider =TestData)
public void Test(String s){

驱动程序。 get(baseUrl);

Assert.assertTrue(driver.getTitle()。contains(s),Ошибка);
}

@AfterSuite
public void tearDown()throws Exception {
driver.quit();
}
}



在测试结果输出中,我看到:



java.lang.AssertionError:Ошибка
预期:true
实际:false



另一个问题,如果我在DataProvider中使用cyrillic,那么在测试树中我看到Test(РћС€Р)而不是Test(Гугл)

解决方案

这是一个已知错误,将被修复



目前的解决方法是编辑。vmoptions文件并添加 -Dfile.encoding = UTF-8 选项。


I am using IntelliJ IDEA 12.0.4. Have some tests. When i'm running one using JUnit4 framework my Assertion Error looks like:

java.lang.AssertionError: Status should be: Черновик expected [true] but found [false]

If i am using a TestNG it look like this:

java.lang.AssertionError: Status should be: Черновик expected [true] but found [false]

All other cyrillic outputs work fine on both framework, only assertion text won't.

Project files encoding set to UTF-8.

Update: For example simple WebDriver test. I use TestNG and IE.

import org.testng.Assert;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

import java.util.concurrent.TimeUnit;


public class SeleniumExample  {

    protected WebDriver driver;
    protected String baseUrl;

    @BeforeSuite
    public void setUp() throws Exception
    {

        /* Local Driver  */
        driver = new InternetExplorerDriver();
        baseUrl = "http://www.google.com";
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    }

    @DataProvider
    public Object[][] TestData() {
        return new Object[][]{
                {"Гугл"},
        };
    }

    @Test(description = "Create_InvestProjectRequest", dataProvider = "TestData")
    public void Test(String s) {

        driver.get(baseUrl);

        Assert.assertTrue(driver.getTitle().contains(s), "Ошибка");
    }

    @AfterSuite
    public void tearDown() throws Exception {
        driver.quit();
    }
}

In Test Result output i see:

java.lang.AssertionError: Ошибка Expected :true Actual :false

And another problem that if i use cyrillic in DataProvider, then in Test tree i see Test("РћС€Р") instead of Test("Гугл")

解决方案

It's a known bug that will be fixed in the next update, thanks for your project that helped us to trace it.

Current workaround is to edit the .vmoptions file and add -Dfile.encoding=UTF-8 option.

这篇关于AssertionError的IDEA输出中的字符编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆