Linked Questions

43 votes
2 answers
103k views

I have a test that is using some Spring contexts. In these contexts, a number of beans are declared. I want the test to use the actual implementation of the beans of the contexts, EXCEPT for one of ...
Mr.Eddart's user avatar
  • 10.3k
1 vote
1 answer
2k views

I want to write a test for a printing service. I am using Spring with TestNG and Mockito. So far I've created a test configuration class for my spring context and the needed test class. The ...
Tobias Timm's user avatar
  • 2,120
0 votes
1 answer
726 views

I'm trying to test some controller with method-level spring security and I want to mock out the repository dependencies in the controller. Basically I want to test that (a) the methods are enforcing ...
Grant Lay's user avatar
  • 859
79 votes
7 answers
121k views

I started to learn about Mockito only today. I wrote some simple test (with JUnit, see below), but I can't figure out how can I use mock object inside Spring's managed beans. What is best practices ...
alexsmail's user avatar
  • 5,823
27 votes
5 answers
23k views

I have several integration tests running on Spring Framework that extend the base class called BaseITCase. Like this: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {...
dvelopp's user avatar
  • 4,345
22 votes
4 answers
55k views

Here's my question: I have several web services classes to test that all inherit their methods from a generic service. Rather than write a unit test for each, I figure I can break the test suite down ...
DYezek's user avatar
  • 344
33 votes
3 answers
33k views

A simple question that might have an advanced answer. The Question: My question is, is there a way to instantiate only the classes, in your application context, needed for that specific JUnit test ? ...
SandMan's user avatar
  • 575
13 votes
5 answers
12k views

I have a drools rule file which uses service classes in the rules. So one rule does something like this: eval(countryService.getCountryById(1) != null) In a validationservice that is annotated with @...
Michael's user avatar
  • 233
8 votes
6 answers
12k views

I am using spring in my application and I want to write unit tests for all my classes. I call few external webservices from my application and i want to mock them using Mockito since I just want to ...
rahul's user avatar
  • 393
9 votes
5 answers
8k views

I have to write tests with String Test framework where many DB connections was used. In test I don't need all data sources but Spring want them all to inject. Are there any standard or well known ...
gavenkoa's user avatar
  • 49.7k
3 votes
3 answers
24k views

As I am new to Spring Test MVC I don't understand this problem. I took the code below from http://markchensblog.blogspot.in/search/label/Spring Variable mockproductService is not injected from ...
Human Being's user avatar
  • 8,447
6 votes
5 answers
11k views

My question is very similar to the issue raised in Injecting Mockito mocks into a Spring bean. In fact, I believe the accepted answer there might actually work for me. However, I've got one issue ...
Mike's user avatar
  • 8,092
8 votes
1 answer
4k views

I'm starting on testing applications in general and I want to create several tests to learn Mockito in Spring. I've been reading several information but I have some general doubts I'd like to ask. I ...
Juanillo's user avatar
  • 875
4 votes
3 answers
8k views

I'd like to continue this question. These answers foo and bar are exactly what I would need. But for the bar example spring doesn't infer the type of bean that is returned from generic mock() method....
lisak's user avatar
  • 22k
2 votes
2 answers
10k views

I'm trying to autowire a mocked DAO object for my Spring (v. 3.1.0.RELEASE) test and using Mockito 1.9.0. The controller class with the field I want to mock is @Controller @RequestMapping("/...
Dave's user avatar
  • 20.1k

15 30 50 per page