RunAs Elevated

TAEF ensures that the test is run in an elevated process by spawning an elevated process to run the test if necessary.

Note: The user executing TAEF must be a member of the administrators group in order to execute tests marked with RunAs=Elevated. This is due to the fact that non-admins do not have a split token to elevate. If a non-admin attempts to run a test which is marked with RunAs=Elevated, the test will be marked as blocked.

Note  On computers running versions of Windows older than Windows Vista, you must run elevated tests from an administrator process.

Specifying RunAs on the Command Line

te unittests\* /runas:elevated

Marking Tests with RunAs

Test metadata can be used to specify the runas type of an assembly, class or test method.

Note  RunAs values specified in metadata override RunAs values specified on the command line. For example, a test marked with runas:system test metadata will still be run as Local System even if /runas:elevated is specified on the command line.

Example (native code)

class MyTests
{
    TEST_CLASS(MyTests);

    BEGIN_TEST_METHOD(ElevatedTest)
        TEST_METHOD_PROPERTY(L"RunAs", L"Elevated")
    END_TEST_METHOD()
};

RunAs