jeudi 15 avril 2021

Are Abstract Unit and Integration Tests good or bad practice?

TL;DR Question: Is it good or bad practice to write Unit and/or Integration tests that are abstract? (Class ABFTest extends AbstractP44Test)

We've started writing Unit Tests before we started automating running them. So I'm in the process of cleaning up a lot of broken tests. Some that were written for a specific environment, or just no longer work.

I've come across a large abstract class that other tests are dependant on. A lot of the logic in it and its children seem like they need tests themselves.

Is there a smart way to do abstract tests to avoid rewriting code? Or is it a bad practice in general to do this? Should tests always be isolated?

We're new to testing and haven't worked out how things should be done overall.

Bonus: I'm currently marking abstract test classes as ignore with PHPUnit. Does that also ignore all of its children?

protected function setUp(): void
{
    self::markTestSkipped('Abstract Test');
}

Aucun commentaire:

Enregistrer un commentaire