Character encoding in IDEA output of AssertionError

泪湿孤枕 提交于 2019-12-21 17:25:58

问题


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("Гугл")


回答1:


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.



来源:https://stackoverflow.com/questions/16081657/character-encoding-in-idea-output-of-assertionerror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!