Показывание различий между несуществующими строками с использованием assertjJAVA

Программисты JAVA общаются здесь
Anonymous
Показывание различий между несуществующими строками с использованием assertj

Сообщение Anonymous »

В настоящее время я работаю над модульным тестом для функции Kotlin, которая будет генерировать файл CSV из некоторых данных модели. Я сталкиваюсь с некоторыми странными сбоями теста, и вывод по умолчанию от AssertJ не очень помогает в диагностике проблемы. Из того, что я могу сказать, сбой вызван кодированием персонажа. Сообщение «ожидало x, но было y», - ничего не говорит мне, так как X и Y кажутся такими же. Есть ли способ получить тестовый вывод, чтобы отобразить точно, какие символы не совпадают в строках?internal fun List.buildCsv(dp: INT293DependencyProvider):File
{
val file = File("/tmp/${dp.outputFileName}.csv")
file.bufferedWriter(Charsets.ISO_8859_1).use { out ->

out.write(RaveOutput.HEADER)
this.forEach {
out.write(it.toCsvRow())
}
}
return file
}

@Test
fun `Test generate csv from contacts`()
{

mockContext(300).value().let { context ->
testInt293DependencyProvider(context).let { dp ->
javaClass.classLoader.getResourceAsStream("rave-contacts.csv").use { stream ->
val expected = IOUtils.toString(stream, Charsets.ISO_8859_1)

val contacts = listOf(
Contact("123456", "foo", "bar", "foo@bar.com", "5704445555", Type.EMPLOYEE, "fbar"),
Contact("654321", "john", "doe", "jdoe@bucknell.edu", "+15556667777", Type.STUDENT, "jdoe")
)
val output = contacts.buildCsv(dp)

val actual = IOUtils.toString(output.inputStream(), Charsets.ISO_8859_1)

assertNotNull(actual)
assertThat(actual).isEqualTo(expected)

}
}
}
}

[ERROR] Test.Test generate csv from contacts
expected:
"Unique Loader ID,Last Name,First Name,Registration Email Address,Email Address 2,Email Address 3,Site Username,Role,Mobile Phone 1,Mobile Phone 2,Mobile Phone 3,Mobile 1 Voice,Mobile 2 Voice,Mobile 3 Voice,Mobile Carrier 1,Mobile Carrier 2,Mobile Carrier 3,Landline Phone 1,Landline 1 Extension,Landline Phone 2,Landline 2 Extension,Landline Phone 3,Landline 3 Extension,Language Preference,Notify by SMS,Notify by Email,String Attribute 1,String Attribute 2,String Attribute 3,String Attribute 4,String Attribute 5,String Attribute 6,String Attribute 7,String Attribute 8,String Attribute 9,String Attribute 10,String Attribute 11,String Attribute 12,String Attribute 13,String Attribute 14,String Attribute 15,String Attribute 16,String Attribute 17,String Attribute 18,String Attribute 19,String Attribute 20,Integer Attribute 1,Integer Attribute 2,Integer Attribute 3,Integer Attribute 4,Integer Attribute 5,True/False Attribute 1,True/False Attribute 2,True/False Attribute 3,True/False Attribute 4,True/False Attribute 5,Date Attribute 1,Date Attribute 2,Date Attribute 3,Date Attribute 4,Date Attribute 5
123456,bar,foo,foo@bar.com,,,fbar,EMPLOYEE,5704445555,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
654321,doe,john,jdoe@bucknell.edu,,,jdoe,STUDENT,+15556667777,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"
but was:
"Unique Loader ID,Last Name,First Name,Registration Email Address,Email Address 2,Email Address 3,Site Username,Role,Mobile Phone 1,Mobile Phone 2,Mobile Phone 3,Mobile 1 Voice,Mobile 2 Voice,Mobile 3 Voice,Mobile Carrier 1,Mobile Carrier 2,Mobile Carrier 3,Landline Phone 1,Landline 1 Extension,Landline Phone 2,Landline 2 Extension,Landline Phone 3,Landline 3 Extension,Language Preference,Notify by SMS,Notify by Email,String Attribute 1,String Attribute 2,String Attribute 3,String Attribute 4,String Attribute 5,String Attribute 6,String Attribute 7,String Attribute 8,String Attribute 9,String Attribute 10,String Attribute 11,String Attribute 12,String Attribute 13,String Attribute 14,String Attribute 15,String Attribute 16,String Attribute 17,String Attribute 18,String Attribute 19,String Attribute 20,Integer Attribute 1,Integer Attribute 2,Integer Attribute 3,Integer Attribute 4,Integer Attribute 5,True/False Attribute 1,True/False Attribute 2,True/False Attribute 3,True/False Attribute 4,True/False Attribute 5,Date Attribute 1,Date Attribute 2,Date Attribute 3,Date Attribute 4,Date Attribute 5
123456,bar,foo,foo@bar.com,,,fbar,EMPLOYEE,5704445555,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
654321,doe,john,jdoe@bucknell.edu,,,jdoe,STUDENT,+15556667777,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"


Подробнее здесь: https://stackoverflow.com/questions/795 ... ng-assertj

Вернуться в «JAVA»