Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Character encoding in IDEA output of AssertionError

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

like image 339
QAutomatron Avatar asked Nov 02 '22 23:11

QAutomatron


1 Answers

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.

like image 91
CrazyCoder Avatar answered Nov 13 '22 03:11

CrazyCoder