How can I call tests from another test?
I have a class in the jar that I have added as dependency into my project:
public class Tests{
private MockMvc mockMvc;
@Test
public void test1() throws Exception {
.....
mockMvc.perform(get(myRequest)
.content(dataFromDB)
.......
}
}
@Test
public void test2() throws Exception {
.....
mockMvc.perform(get(myRequest)
.content(dataFromDB)
.......
}
}
.......
And in my project I have:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = MyApp.class)
public class MyTests {
private MockMvc mockMvc;
@Autowired
private WebApplicationContext context;
@Before
public void init() throws Exception {
MockitoAnnotations.initMocks(this);
mockMvc = MockMvcBuilders.webAppContextSetup(context).apply(springSecurity()).build();
}
@Test
public void test() throws Exception {
CALL SOMEHOW TESTS FROM THE JAR HERE
}
I want those tests from the jar to test my project's database (for example: dataFromDB should be some data from the project where this dependency has been added).
I have already added this jar and I can call class Tests inside my project,so I have access to it. I am just not sure how to run those tests inside it.
What should I change so it works well? Thanks
Aucun commentaire:
Enregistrer un commentaire