Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test framework allowing tests to depend on other tests

I'm wondering if there is a test framework that allows for tests to be declared as being dependent on other tests. This would imply that they should not be run, or that their results should not be prominently displayed, if the tests that they depend on do not pass.

The point of such a setup would be to allow the root cause to be more readily determined in a situation where there are many test failures.

As a bonus, it would be great if there some way to use an object created with one test as a fixture for other tests.

Is this feature set provided by any of the Python testing frameworks? Or would such an approach be antithetical to unit testing's underlying philosophy?

like image 737
intuited Avatar asked Oct 07 '10 20:10

intuited


People also ask

Should tests depend on each other?

Tests should never depend on each other. If your tests have to be run in a specific order, then you need to change your tests. Instead, you should make proper use of the Setup and TearDown features of your unit-testing framework to ensure each test is ready to run individually.

Can unit tests depend on each other?

Unit tests should not affect each other. Unit tests should be deterministic. Unit tests should not depend on any external state.

How do you test one dependent on another TestNG?

Using 'dependsOnMethod' attribute within @Test annotation, we can specify the name of parent test method on which the test should be dependent. On execution of the whole test class or test suite, the parentTest method will run before the dependentTest.

What is meant by integration testing?

Integration testing -- also known as integration and testing (I&T) -- is a type of software testing in which the different units, modules or components of a software application are tested as a combined entity. However, these modules may be coded by different programmers.


2 Answers

Or would such an approach be antithetical to unit testing's underlying philosophy?

Yep...if it is a unit test, it should be able to run on its own. Anytime I have found someone wanting to create dependencies on tests was due to the code being structured in a poor manner. I am not saying this is the instance in your case but it can often be a sign of code smell.

like image 164
Aaron McIver Avatar answered Sep 28 '22 05:09

Aaron McIver


Proboscis is a Python test framework that extends Python’s built-in unittest module and Nose with features from TestNG.

Sounds like what you're looking for. Note that it works a bit differently to unittest and Nose, but that page explains how it works pretty well.

like image 33
naught101 Avatar answered Sep 28 '22 05:09

naught101