Cannot Resolve Symbol 'Assertdoesnotthrow'

Cannot Resolve Symbol 'Assertdoesnotthrow'

I have some problem with In intellij. I try to import the following library:

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;

But I get the following error:

cannot resolve symbol 'assertDoesNotThrow'

But I don't get errors for assertEquals.

The use:

assertDoesNotThrow(() -> r1.rate(new Pro(1, "xyz"), 0));
assertDoesNotThrow(() -> r1.rate(new Pro(1, "xyz"), 5));

I guess this is some problem with JUInt, but I can't seem to find the solution. I have tried some previous threads but without success.

5

1 Answer

When you add JUnit library in IntelliJ IDEA via the intention action, there is a choice which library version to add:

If you add 5.3 version, you will see the following in the Module Dependencies:

In case you have some older version there, delete these libraries and add the correct version again.

Refer to the Configuring Testing Libraries help section.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Maya Lin-Takahashi
Author

Maya Lin-Takahashi

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.