我正在使用 IntelliJ IDEA 12.0.4。
进行一些测试。当我使用 JUnit4 框架运行一个时,我的断言错误看起来像:
java.lang.AssertionError: Status should be: Черновик expected [true] but found [false]
如果我使用的是 TestNG,它看起来像这样:
java.lang.AssertionError: Status should be: Черновик expected [true] but found [false]
所有其他西里尔文输出在两个框架上都可以正常工作,只有断言文本不会。
项目文件编码设置为 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
{
/* 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();
}
}
在测试结果输出中,我看到:
java.lang.AssertionError: Ошибка
预期:真
实际:假
另一个问题是,如果我在 DataProvider 中使用西里尔文,那么在测试树中我会看到 Test("РћС€Р") 而不是 Test("Гугл")
最佳答案
这是一个 known bug这将在下一次更新中修复,感谢您的项目帮助我们追踪它。
当前的解决方法是编辑 .vmoptions file并添加 -Dfile.encoding=UTF-8
选项。
关于character-encoding - AssertionError 的 IDEA 输出中的字符编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16081657/