mardi 21 avril 2015

Unit Test with Mock

I want to test my API and I use a mock. I have a method to test the good comportment of my API :

    @Test
    @Transactional
    public void requestShouldReturnCode200() throws Exception {     
        restMeteoMockMvc.perform(get("/api/myAPI/{param1},{param2}", GOOD_PARAM1, GOOD_PARAM2)
                .accept(TestUtil.APPLICATION_JSON_UTF8))
                .andExpect(status().isOk());
    }

The signature of the method I want test is :

public ResponseEntity<Object> get(@PathVariable Float param1, @PathVariable Float param2)

I think I made a mistake in the way to send parameters of the method to test... Isn't it ? Because in my redirect file for the results of the test, I can see that requestShouldReturnCode200 received a 400 code and expected 200.

Aucun commentaire:

Enregistrer un commentaire