Hi everyone! I have a rather strange situation: I ...
# getting-started
p
Hi everyone! I have a rather strange situation: I am testing my library with JUnit (as it was in many guides) and they are working correctly on my local machine, but on Github Actions they fail with really strange exception:
Copy code
Caused by:
        org.opentest4j.AssertionFailedError: Array elements differ at index 0. Expected element <Lesson(place=4, timeConstraints=TimeConstraints(startHour=11, startMinute=25, endHour=12, endMinute=10), title=Биология, classID=8, teacherID=104631, journalID=null)>, actual element <Lesson(place=4, timeConstraints=TimeConstraints(startHour=11, startMinute=25, endHour=12, endMinute=10), title=Биология, classID=8, teacherID=104631, journalID=100125)>.
        Expected <[Lesson(place=4, timeConstraints=TimeConstraints(startHour=11, startMinute=25, endHour=12, endMinute=10), title=Биология, classID=8, teacherID=104631, journalID=null)]>, actual <[Lesson(place=4, timeConstraints=TimeConstraints(startHour=11, startMinute=25, endHour=12, endMinute=10), title=Биология, classID=8, teacherID=104631, journalID=100125)]>.
The most bizzare part of that assertion fail is part with
journalID=null
in expected element. The problem is that there are no null journal ID's in tests. Does anybody know what is my problem? Source code for tests (the failing one is marked): https://github.com/Neitex/Schools_Parser/blob/74c9fb9ed14b47cce4d173dc288d0a91a088b3ed/src/test/kotlin/com/neitex/SchoolsByParserTest.kt#L430 Source code of Lesson constructor (this is a regular data class, nothing special): https://github.com/Neitex/Schools_Parser/blob/74c9fb9ed14b47cce4d173dc288d0a91a088b3ed/src/main/kotlin/com/neitex/DataClasses.kt#L63 Thanks in advance!
r
You have your expected and your actual the wrong way around
See https://kotlinlang.org/api/latest/kotlin.test/kotlin.test/assert-content-equals.html - the first argument is the expectation, the second argument is the actual value
So the
null
journal id is actually in
timetable.wednesday.first[0]
p
Oh, shoot. Didn't notice that 🙂 Thanks a lot! Have a great day!