The library is throwing an AssertionError which makes my tests fail

I was working on creating a unit test for my java project and my test keeps failing even though I didn't make any assertions.

After reading the stacktrace, I noticed that the method in the retsIQ library that I am using is throwing an assertion error. Anyway, can I ignore this? I would rather not decompile and recompile the module.

I should also mention that this exact code works great if it doesn't run as a test.

Here is a photo of my test: Unit Test

Here's a picture it doesn't work in the test: enter image description here

+3


source to share


2 answers


I'll take on two things: 1) your project is maven based; 2) these two pieces of code are exactly the same (except for the line assertTrue(true);

that doesn't do anything by the way).

It is possible that your problem is caused by the fact that the "run" and "test" configurations have different classes. Perhaps you have the wrong version of some library in your test class, or even miss some library, which ultimately leads to this exception.

I suggest you double-check all test-scope dependent dependencies in the pom.xml. You can also print the project dependency tree using the Maven Dependency Plugin (but I'm not sure if it can print the test dependencies separately):



mvn dependency:tree -Dverbose

      

Alternatively, you can go to Project Structure> Modules> Dependencies tab in Intellij Idea and view all entries with Test area.

+1


source


From the stacktrace, it looks like unexpected data was found while parsing the response. The best way to diagnose the problem is to set a breakpoint at SearchCompactReader.parse()

(near line 16) and run the test in the debugger.



By the way, your test is not a unit test. A unit test tests an individual class or method separately. It seems like your test hit a live server.

0


source







All Articles