Condividi tramite


Sistema RunAs

TAEF esegue il test come sistema locale.

Annotazioni

I test eseguiti come sistema locale non devono creare interfacce utente.The tests that you run as Local System should not create any user interfaces (UI). Se i test devono creare o interagire con l'interfaccia utente, è necessario spostare il codice correlato all'interfaccia utente in file eseguibili separati avviati su un desktop dai test usando la funzione CreateProcessAsUser.

Specifica di RunAs nella riga di comando

te unittests\* /runas:system

Contrassegno dei test con RunAs

I metadati di test possono essere usati per specificare il tipo runas di un assembly, una classe o un metodo di test.

Annotazioni

I valori RunAs specificati nei metadati sostituiscono i valori RunAs specificati nella riga di comando. Ad esempio, un test contrassegnato con i metadati di test runas:system verrà comunque eseguito come sistema locale anche se /runas:elevated è specificato nella riga di comando.

Esempio (codice nativo)

class MyTests
{
    TEST_CLASS(MyTests);

    BEGIN_TEST_METHOD(SystemTest)
        TEST_METHOD_PROPERTY(L"RunAs", L"System")
    END_TEST_METHOD()
};

RunAs