0

I am implementing tests depending on private test framework, but I found no proper assert method to stop the test. So I try use Assert class in Junit. But always get below error. Is it true I can't use Assert in Junit if I am not using its framework(Run as Junit test)?

Caused by: java.lang.ClassNotFoundException: junit.framework.Assert
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)

btw, what it should be for Junit path?

Catheryan
  • 111
  • 1
  • 1
  • 8

2 Answers2

0

Have a look at Hamcrest if you're looking for an assertion library.

Stefan Birkner
  • 24,059
  • 12
  • 57
  • 72
-1

You cannot use JUnit's Assert outside of JUnit tests.

However, you can just use Java's assert keyword instead.

Here is a comparison between the two.

Community
  • 1
  • 1
Domi
  • 22,151
  • 15
  • 92
  • 122