I did not add this feature to TestNG because at that time I had no convincing use cases to justify it. Since then, I have gathered some use cases, and will add a function to the next version of ScalaTest to refer to it. But these will not be dependent tests, but simply a way to βcancelβ a test based on an unsatisfied prerequisite.
In the meantime, you can simply use the Scala if commands only to register tests if the condition is met, or register them as ignored if you prefer to see their output. If you use Spec, it looks something like this:
if (databaseIsAvailable) { it("should do something that requires the database") {
This will only work if the condition is met exactly at the time the test is built. Perhaps if, for example, it is assumed that the database is started by the beforeAll method, you will need to perform a check inside each test. And in this case, you could say that it is under consideration. Sort of:
it("should do something that requires the database") { if (!databaseIsAvailable) pending // ... } it("should do something else that requires the database") { if (!databaseIsAvailable) pending // ... }
source share