Setting up UserNameEnvironmentVariableFixture
Done setting up UserNameEnvironmentVariableFixture: Set the UserName environment variable to "David".
Running testA
Current UserName: "David".
Done testA
Tearing down UserNameEnvironmentVariableFixture
Done tearing down UserNameEnvironmentVariableFixture: Restored the UserName environment variable to "Kim".
Setting up UserNameEnvironmentVariableFixture
Done setting up UserNameEnvironmentVariableFixture: Set the UserName environment variable to "Andy".
Running testB
Current UserName: "Andy".
Done testB
Running testC
Current UserName: "Andy".
Done testC
Tearing down UserNameEnvironmentVariableFixture
Done tearing down UserNameEnvironmentVariableFixture: Restored the UserName environment variable to "Kim".
Recall that the fixtures are compatible if their UserName properties match. The tests in
testA and testB use incompatible shared fixtures, since 'David' is not equal to
'Andy'. Therefore, the framework invokes the fixture teardown and setup methods
between calls to testA and testB. However, the shared test fixture in testC is
compatible with the fixture in testB, so the framework doesn’t repeat fixture teardown
and setup before testC.
Alternative Approach to Calling addTeardown in setup Method
An alternate approach to using the addTeardown method within the setup method is to
implement a separate teardown method. Instead of the setup method described above,
implement the following setup and teardown methods within
UserNameEnvironmentVariableFixture.m.
Create Advanced Custom Fixture