Repository navigation
Closed
Description
run spring test cases in paralleled way got errors.
I am trying to make the spring tests run faster, now I am using bazel, but the speed is not fast enough, now I want to run the spring test cases in paralleled way, so I modified the bazel's source code a little, the changed code is here https://github.com/ddwolf/bazel/commit/d7e370c38a6a64b2e987b7f942241733cdc01c17
and the test case is here
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = ControllerConfiguration.class)
@WebAppConfiguration
public class EnvironmentControllerIntegrationTests {
@Autowired
private WebApplicationContext context;
private MockMvc mvc;
private EnvironmentRepository repository;
@Autowired
private void setEnvironmentRepository(EnvironmentRepository repo){
if(null == repo) return;
this.repository=repo;
}
@Before
public void init() {
Mockito.reset(this.repository);
this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
}
@Test
public void environmentWithLabelContainingSlash() throws Exception {
Mockito.when(this.repository.findOne("foo", "default", "feature/puff"))
.thenReturn(new Environment("foo", "default"));
this.mvc.perform(MockMvcRequestBuilders.get("/foo/default/feature(_)puff"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.content().string(Matchers.containsString("\"propertySources\":")));
}
@Configuration
@EnableWebMvc
@Import(PropertyPlaceholderAutoConfiguration.class)
public static class ControllerConfiguration {
@Bean
public EnvironmentRepository environmentRepository() {
EnvironmentRepository repository = Mockito.mock(EnvironmentRepository.class);
return repository;
}
@Bean
public EnvironmentController controller() {
return new EnvironmentController(environmentRepository());
}
}
}the error message I got is
org.mockito.exceptions.misusing.NotAMockException: Argument should be a mock, but is null!
it seems that the @test method runs before the auto wiring phase of spring, can you help with me about this? or where can I get help with?
Thanks.
Environment info
-
Operating System: Ubuntu 14.04
-
Bazel version (output of
bazel info release): bazel-0.4.1
Metadata
Metadata
Assignees
Labels
No labels
Activity
damienmg commentedon Dec 6, 2016
This could be a better discussion on bazel-discuss@ than here (you would get more people to help). The problem is probably than the RunWith annotation might be ignored (
SpringJUnit4ClassRunner). I am totally unfamiliar with the Spring framework.I will close this bug as there is no clear action from use, please port the discussion to [email protected] if you wish to get more help.
ddwolf commentedon Dec 6, 2016
@damienmg OK, thks.