Questions tagged [springrunner]
42 questions
0
votes
0 answers
Spring context doesn't load my class in unittest
I can't get my unit test to load my configuration class.
My test class is annotated:
@RunWith(SpringJUnit4ClassRunner.class)
@ActiveProfiles(profiles = "test")
@ContextConfiguration (classes = ClientConfiguration.class)
public class…

ed4becky
- 1,488
- 1
- 17
- 54
0
votes
1 answer
Unit testing a method of a class that has a constructor and an autowired field that needs to be mocked using mockito
I have a service class that extends another service with a constructor. This class has an autowired field and a method that I wanted to unit test using Mockito. However, I am having trouble writing a unit for it.
Let say the service looks somewhat…

user1892775
- 2,001
- 6
- 37
- 58
0
votes
1 answer
Why do I keep getting 404's when using @AutoConfigureMockMvc in SpringBoot test?
I'm trying to write an integration test using springrunner. I'm running it as a springboottest and using autoconfiguremockmvc. However, i keep getting 404s. It seems my controllers/endpoints aren't being loaded by the autoconfiguremockmvc. Does…

bdeane
- 52
- 9
0
votes
0 answers
Kotlin + Spring 5 functional beans mixed with traditional beans test WITHOUT spring-boot
Suppose I have a class injected many spring beans :
@Component
open class CoreContext {
@Inject
protected lateinit var bean1 : SomeInterface1
@Inject
protected lateinit var bean2 : SomeInterface2
}
It is defined in the…

smallufo
- 11,516
- 20
- 73
- 111
0
votes
1 answer
H2 database testing with mocked service gives nullpointer exception
I am working on a Spring Java-based project.
For testing purposes I have implemented a H2 in-memory DB, which has been filled with data via an xml doc.
I whish to test a method which updates database records via an incoming datagram.
First of all,…

dorcsi
- 295
- 2
- 6
- 24
0
votes
2 answers
Is it good practice to use SpringRunner without SpringContext when writing JUnit test cases?
I tried junit with mockito, and wrote some test cases for a coding exercise.
Here is the test case which i wrote:
@RunWith(SpringRunner.class)
public class TransactionControllerTest {
@Mock
TransactionService transactionServiceMock;
…

KayV
- 12,987
- 11
- 98
- 148
0
votes
0 answers
Set system property for a new thread
I have a piece of application code which retrieves a system property to get log path. This piece of code is executed by a batch job.
I have written a test case using JobLauncherTestUtils class to launch this job. How can i mock the system property.…

poorna chandra
- 27
- 1
- 1
- 8
0
votes
1 answer
SprintBootTest - create only necessary beans
I have a code similar to the follows:
@RunWith(SpringRunner.class)
@SpringBootTest
public class ModelRunnerTest {
@Autowired
private SomeRepository repository;
@Autowired
private SomeSearcher someSearcher;
@Test
public…

user1028741
- 2,745
- 6
- 34
- 68
0
votes
1 answer
org.springframework.messaging.converter.MessageConversionException: Cannot convert
We have an application using Spring Boot and Tibco EMS JMS implementations. When I create the war and deploy on my local Tomcat, I can send and receive the messages with no issues. However, if I run the application from main()…

blueSky
- 649
- 5
- 13
- 31
0
votes
1 answer
How To Handle Exception in Test Case
@RunWith(SpringRunner.class)
@WebMvcTest(MyController.class)
@ContextConfiguration(classes = Application.class)
public class MyControllerTest {
@Autowired
MockMvc mockMvc;
@MockBean
EmployeeService employeeService;
@MockBean
EmployeeRepo…

pasham srinivasarao
- 67
- 1
- 7
0
votes
2 answers
Gradle run test classes in parallel with methods of same class running in same thread
I'm having a few Junit test classes. I want to run them in 2 threads, so included maxParallelForks = 2 . I want to make sure that tests of same class run in same thread sequentially. How to achieve this? (I use SpringRunner.)

Santhosh Kumar
- 314
- 2
- 9
-1
votes
1 answer
When I run springboot using springloaded, it throws exception,why it happens?
When I run springboot using springloaded, it throws exception, why it happens?
The exceptions is below:
[INFO] --- spring-boot-maven-plugin:1.5.13.RELEASE:run (default-cli) @ start ---
[INFO] Attaching agents:…

mike
- 31
- 3