In a spring-mvc project I have a test for the content of the index/homepage:
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
public class HomePageTest {
@Autowired
private MockMvc mockMvc;
@Test
public void shouldContainStrings() throws Exception {
this.mockMvc.perform(get("/")).andDo(print()).andExpect(status().isOk())
.andExpect(content().string(containsString("Hello World")));
}
}
This test works fine so far. But now I would like to test for the occurrence of the strings "Login" or (excl) "Logout", i.e. I want to test whether exactly one (not zero and not both) of these two strings appears in the content. How can I match this or condition?
Aucun commentaire:
Enregistrer un commentaire