C# unit testing - ordered test with runsettings file -


i'm trying develope automated regression test framework unit tests. use ordered test combine different test steps , combine them in easy use way. configuration purposes wanna use runsettings file, testrunparameters. works without errors while executing each test itself. if execute tests using orderedtest, testcontext object use access testrunparameters doesn't contain them anymore. debuged object while testing method directly , while testing ordered tests well. in first scenario object has needed properties when executing tests orderedtest object looks total different. there majore difference between these 2 types of execution?

the different testcontext objects:

execution single test picture
execution ordered test picture

the error following:

ergebnis stacktrace:    @ regression.filesystem.filesystemtestinitializer(testcontext context) in \filesystem.cs:line 18  ergebnis meldung:   class initialization method regression.filesystemtestinitializer threw exception. system.nullreferenceexception: system.nullreferenceexception: object reference not set instance of object.. 

the code execute test , load settings follwing:

 namespace regression {     [testclass]     public class filesystem     {         private static logger logger = logmanager.getcurrentclasslogger();         private static dictionary<string, string> runsettings = new dictionary<string, string>();          [classinitialize]         public static void filesystemtestinitializer(testcontext context)         {             runsettings.add("scenarioname", context.properties["scenarioname"].tostring());             runsettings.add("testrootdir", context.properties["testrootdir"].tostring());         }          [testmethod]         public void action_filesystem_cleanup()         {             directoryinfo dir = new directoryinfo(runsettings["testrootdir"] + runsettings["scenarioname"] + @"\testdata\");             foreach(fileinfo file in dir.getfiles())             {                 file.delete();             }             foreach (directoryinfo childdir in dir.getdirectories())             {                 childdir.delete(true);             }              directorycopy(runsettings["testrootdir"] + runsettings["scenarioname"] + @"\testdata_backup\", runsettings["testrootdir"] + runsettings["scenarioname"] + @"\testdata\", true);         } 

the error comes on line 11 following:

runsettings.add("scenarioname", context.properties["scenarioname"].tostring()); 

the runsettings file included test execution of visual studio:

<runsettings>   <!-- parameters used tests @ runtime -->   <testrunparameters>     <parameter name="scenarioname" value="filesystem_sharepointonline_unidirectional"/>     <parameter name="testrootdir" value="c:\testfiles\"/>   </testrunparameters> </runsettings> 


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -