Test Structure

Top  Previous  Next

Isolator++ Professional supports the AAA (arrange-act-assert) style of unit tests, where a test looks like this:

 

·Arrange various fake objects, and the code under test - this is the setup code
·Act on the code under test - invoking the tested code
·Assert that a method on the fake objects was called - Verify calls were made

 

 

One extra step is needed: calling ISOLATOR_CLEANUP at the end of each unit test. The best place to add this is in the teardown method

Keeping a consistent structure allows the tests to be more readable to casual readers or new developers on your team.

 

GTest

 

class MyTests: public ::testing::Test

{

public:

 virtual void TearDown() 

 {

         ISOLATOR_CLEANUP();

 }

};

 

 

MSTest

 

TEST_CLASS(Conditional)

{

public:

 TEST_METHOD_CLEANUP(TearDown)

 {

         ISOLATOR_CLEANUP();

 }

 


Copyright  Typemock Ltd. 2009-2025.  All Rights Reserved.