Header file and CPP file for creating a test suite in active environment

The following example demonstrates how to write a header file and CPP file for creating a test suite of unit tests to run within an active environment:

Header file

/*
 * @file CTestAsyncSuite.h
 *
 * Copyright (c) 2004 Symbian Ltd.  All rights reserved.
 */

#ifndef __TEST_ASYNC_SUITE__
#define __TEST_ASYNC_SUITE__

#include "TEFUnit.h"

class CTestAsyncSuite : public CActiveTestFixture 
    {
public:
    // SetUp and TearDown code 
    virtual void SetupL();
    virtual void TearDownL();

    // Tests
    void TestOne();
    void TestTwo();

    // Create a suite of all the tests
    static CtestSuite* CreateSuiteL(const TDesC& aName);

private:
    CactiveScheduler* iSched;
    };

#endif // __TEST_ASYNC_SUITE__

CPP file

/**
 * @file CtestAsyncSuite.cpp
 *
 * Copyright (c) 2004 Symbian Ltd.  All rights reserved.
 */

#include "CtestAsyncSuite.h"
#include "CtestSubSuite.h"

void CtestAsyncSuite::SetupL()
/**
 * SetupL
 */
    {
    // Setup Code here
    }

void CtestAsyncSuite::TearDownL()
/**
 * TearDownL
 */
    {
    // TearDown Code here
    }

void CTestAsyncSuite::TestOne()
/**
 * TestOne
 */
    {
    INFO_PRINTF1(_L("Running AsyncSuite:One"));
    }

void CTestAsyncSuite::TestTwo()
/**
 * TestTwo
 */
    {
    INFO_PRINTF1(_L("Running AsyncSuite:Two"));
    }

CTestSuite* CTestAsyncSuite::CreateSuiteL( const TDesC& aName )
/**
 * CreateSuiteL
 *
 * @param aName - Suite name
 * @return – Suite
 */
    {
    SUB_SUITE;
    ADD_ASYNC_TEST_STEP( TestOne );
    ADD_ASYNC_TEST_STEP( TestTwo );
    ADD_TEST_SUITE( CTestSubSuite );
    END_SUITE;
    }