java – 使用Junit比较文本文件
作者:互联网
我正在比较junit中的文本文件:
public static void assertReaders(BufferedReader expected,
BufferedReader actual) throws IOException {
String line;
while ((line = expected.readLine()) != null) {
assertEquals(line, actual.readLine());
}
assertNull("Actual had more lines then the expected.", actual.readLine());
assertNull("Expected had more lines then the actual.", expected.readLine());
}
这是比较文本文件的好方法吗?什么是首选?
解决方法:
junit-addons对它有很好的支持:FileAssert
它为您提供以下例外:
junitx.framework.ComparisonFailure: aa Line [3] expected: [b] but was:[a]
标签:java,junit,text-files,compare 来源: https://codeday.me/bug/20190930/1834676.html