Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

running spring tests in paralleled way got errors #2188

Closed
ddwolf opened this issue Dec 6, 2016 · 2 comments
Closed

running spring tests in paralleled way got errors #2188

ddwolf opened this issue Dec 6, 2016 · 2 comments

Comments

@ddwolf
Copy link

ddwolf commented Dec 6, 2016

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

@damienmg
Copy link
Contributor

damienmg commented 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 bazel-discuss@googlegroups.com if you wish to get more help.

@damienmg damienmg closed this as completed Dec 6, 2016
@ddwolf
Copy link
Author

ddwolf commented Dec 6, 2016

@damienmg OK, thks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants