This is what my base test class looks like -
@SpringApplicationConfiguration(classes = ServiceApplication.class)
@WebAppConfiguration
@IntegrationTest("server.port:8084")
public class BaseTestStartService {
//TODO:add basic service test
}
Not sure what is to be implemented in this base class? What is the correct process? The base class is implemented in the tests classes as -
@RunWith(SpringJUnit4ClassRunner.class)
public class TestClass extends BaseTestAPIService{
//add assertions
}
I am trying to implement the correct process so looking for some advice.
Maybe you could give more insight on what exactly your service does and what you want to test, e.g. REST calls with RestTemplate or direct method calls to the component bean.
Either way, some tips might be interesting:
server.port:0
and eventually autowiring an int with@Value("${local.server.port}")
@Before
and@After
anotations to setup a common set of fixtures on the base class;Either way, a common good practice is to keep your services modular and have one different Test Case per
@Test
annotated method. Judging by your configuration it seems you might have a to large service for which you are structuring the tests. Which could be a good practice if you are using Test Driven Development and plan to segregate the tested service later on.