Snippets tagged “junit”
4 snippets use this tag.
- How do I test a class that has private methods, fields or inner classes?Java
To test a class that has private methods, fields, or inner classes, you can do the following:
- How to assert that a certain exception is thrown in JUnit tests?Java
To assert that a certain exception is thrown in a JUnit test, you can use the @Test annotation's expected attribute. Here's an example:
- How to get the path of src/test/resources directory in JUnit?Java
In JUnit, you can use the getClass().getClassLoader().getResource("").getPath() method to get the path of the src/test/resources directory.
- Testing Private method using mockitoJava
It is generally considered bad practice to test private methods, as they are an implementation detail that should not be exposed to the outside world.