Skip to content

Tag: junit

Difference between junit-jupiter-api and junit-jupiter-engine

What’s the difference between maven modules junit-jupiter-api and junit-jupiter-engine? Is it necessary to include both dependencies in build.gradle? Do I need to provide both dependencies? Or only one dependency is enough? And do I need to add a dependency on junit-vintage-engine? Answer JUnit Prior to Version 5.4 From the docs: junit-jupiter-api JUnit Jupiter API for writing tests and extensions. junit-jupiter-engine

Spring Test cannot get Spring Configuration Beans

I also tried putting EnvironmentServiceTestConfiguration as a non-inner non-static class, but didn’t help. Here is what I tried in a separate class: didn’t work either The test class is located in test/java/com.bhavya.test package. I am trying to run this particular test test1 This is my first test of such kind. I have never before used AnnotationConfigContextLoader.class, enlighten me. Stacktrace :

Android Espresso: How to create test-suite which may launch separate test classes with different activities?

I have just started studying Espresso tests, but I have searched throw StackOverFlow topics and couldn’t found solution for my needs. Prehistory of my question: I have android application with lots of activities. Generally separate UI tests were created for different flows of the app (each flow require separate activity, so that’s why I have implemented tests in a different

Junit test for model class

This question is about best practice rather than any issues or problem. I have a service method below that I am trying to test. myDAO is DAO class that will be injected and has all database call code. And my Junit test case using mockito is Everything is fine and working. My main problem here is MyObject is a modal

JUnitParams with Mockito

This could be a XY problem but I want to ask: I am using JUnitParams to be able to run my test method 10 times with different objects. The problem is that the injections don’t work (@Mock and @InjectMocks). I can use to mock the PersonService in the @Test method. But how do mock the “main” object that is annotated

How to mock a Files static method with Mockito

I have a method in my utilities: I want to mock Files so I can test to make sure Files.createDirectories with the expected fields are called or not. Can I do this with Mockito? Or do I need to actually create the directories and check for their existence in some tmp folder? Answer When you write something with tdd and

Spring Boot Application is starting up from a JUnit test but unable to access through URL

I have a JUnit Test that starts my spring boot appcliation ( If I run the JUnit test, Application is successfully starting up, but not accessible through url Application Logs: When I tried to access the application through url ‘http://localhost:8080/process’, It says Site can’t be reached. Answer Why would you do such thing? This should be a unit test and