Skip to content

Instantly share code, notes, and snippets.

@jenciso
Created December 20, 2021 02:54
Show Gist options
  • Save jenciso/ae8af51e37e62f46703d5944f59c9c10 to your computer and use it in GitHub Desktop.
Save jenciso/ae8af51e37e62f46703d5944f59c9c10 to your computer and use it in GitHub Desktop.
package hello;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = App.class)
@AutoConfigureMockMvc
public class AppTest {
@Autowired
private MockMvc mvc;
@Test
public void helloGradle() throws Exception {
mvc.perform(get("/"))
.andExpect(status().isOk())
.andExpect(content().string("Hello Gradle!"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment