Context
I'm struggling to write a set of unit-tests for a library/framework I'm designing. For context, please, think of my library as an object layer over a hierarchical set of related objects.
Question
Basically, I'm trying to adhere to the principles and best practices regarding unit testing as seen in some posts here, but they seem conflicting with regards to specifically unit testing a library or framework.
For instance, a basic test concerns itself with "creating an artifact". And another one with "removing an artifact". But, since a unit test is supposed to be standalone and restore the state of the world after its completion, both those tests seem somewhat related anyway : when testing the artifact creation, we need to cleanup the state at the end of the test by actually removing it. This means that artifact removal is itself implicitly tested. And the same reasoning applies to testing artifact removal : in order to setup the world so that artifact removal is testable, we need to create a new artifact first.
The situation is compounded when we need to unit test the creation and removal of related sub-artifacts, for which we will need to setup the world accordingly.
What I'm leaning towards is perform a set of related unit tests in sequence, so that each unit test is discrete (i.e. only tests one thing and one thing only), but depends on previous tests in the sequence to progressively setup the world. Then, my sequence could look like this:
[create artifact]->[create sub artifact]->[remove sub artifact]->[remove artifact]
With this principle, the entire library/framework is unit-tested, and the state of the world is restored at the end of the entire run of the test suite. However, this means that any failure in the middle of the test suite "breaks the world".
What are some best practices and guidelines that may be useful to reconcile those conflicting needs?