Reputation: 2570
I have a service that when it's being loaded, it takes a while (few minutes) until all the information is getting into the database.
If I run the tests prematurely, they will fail for that reason (missing items in DB).
Is there some REST assured feature to deal with it? Or I need to have my own mechanism to do that?
Upvotes: 1
Views: 1373
Reputation: 8676
Rest-Assured cannot decide if the service has started unless the service itself provides the endpoint to check its status. Moreover Rest-Assured does not manage test life-cycle.
But JUnit does. You can achieve what you need by coding the condition logic in @BeforeAll
and @BeforeEach
methods like this:
boolean serviceStarted = false;
@BeforeAll
public void waitForServiceStart(){
try{
// Wait for conditions here
serviceStarted = true;
}catch (Throwable e){
// Process exception here
}
}
@BeforeEach
public void makeSureEverythingIsReady(){
Assumptions.assumeTrue(serviceStarted);
}
Upvotes: 2