sjn*_*ngm 3 eclipse unicode junit infinitest
我在Eclipse中使用的是无限的,我和JUnit有一个奇怪的现象.
我有使用org.apache.http.HttpResponse.getEntity()和的代码org.apache.http.entity.StringEntity.JUnit测试如下所示:
@Test
public void convertEncodedContentToString() throws UnsupportedEncodingException {
HttpResponse httpResponseMock = Mockito.mock(HttpResponse.class);
Mockito.when(httpResponseMock.getEntity()).thenReturn(new StringEntity("huiäöüß@€", HTTP.UTF_8));
Assert.assertEquals("huiäöüß@€", parser.convertContentToString(httpResponseMock));
}
Run Code Online (Sandbox Code Playgroud)
所有源文件都以UTF-8存储.
如果我让JUnit执行此方法,它可以正常工作.
但是,如果无限运行此测试,它会抱怨断言失败.
ComparisonFailure (expected:<hui[äöüß@€]> but was:<hui[äöüß@€]>) in ResponseBodyParserFactoryTest.convertEncodedContentToString
Run Code Online (Sandbox Code Playgroud)
显然存在字符编码问题.
由于无限接近没有选项,我不知道如何帮助最有效地运行此测试.有人可以帮帮我吗?
你需要说无限,它必须使用UTF-8字符集来运行测试.
只需在Eclipse项目中添加一个文件:"infinitest.args".在此文件中,添加以下内容:
-Dfile.encoding=UTF-8
Run Code Online (Sandbox Code Playgroud)
所以,inifinitest将使用UTF-8
用户指南:http://infinitest.github.com/doc/user_guide.html特别是"设置JVM选项"部分
| 归档时间: |
|
| 查看次数: |
689 次 |
| 最近记录: |