lundi 17 octobre 2016

Accessing selected tests in visual studio's test explorer in code

Currently, before generating images for our automated image testing project in visual studio, we make a message box appear confirming that the current images should be replaced.

We would like it so that the test names should then appear in the message box of the currently selected tests in visual studio's test explorer tree view. This will hopefully mean that team members can easily double check what tests they are running and avoid making valid images obsolete.

I've attempted to do it through reflection:

private static List<string> GetListOfTestsToBeRun()
{
    Assembly UnitTestAssembly = Assembly.Load("UnitTests");
    Type[] testClasses = UnitTestAssembly.GetTypes();

    List<string> listToReturn = new List<string>();
    foreach (Type testClass in testClasses)
    {
        //Get selected test object (from somewhere...?)
        //Get property from type could then be used (if GenerateExpectedImages
        //was public), or just access the property itself on the object.
        //e.g
        //if testClass.GenerateExpectedImages
        //     Add testclass to listToReturn
    }
    return listToReturn;
}

Is there a better way to do this/ Is this at all possible?





Aucun commentaire:

Enregistrer un commentaire