将文本文件与Junit进行比较 [英] Comparing text files with Junit
本文介绍了将文本文件与Junit进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在比较junit中的文本文件:
I am comparing text files in junit using:
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());
}
这是比较文本文件的好方法吗?什么是首选?
Is this a good way to compare text files? What is preferred?
推荐答案
junit-addons 对它有很好的支持: FileAssert
junit-addons has nice support for it: FileAssert
它为您提供例外情况:
junitx.framework.ComparisonFailure: aa Line [3] expected: [b] but was:[a]
这篇关于将文本文件与Junit进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文