Handling errors in DDT
I've created a DDT "framework" that I use to pass data into a test template.
This is the function that controls the whole thing:
// Start Here function Main() { aqPerformance.Start(); //Used as the master test id var csvPath = "C:\\TestData\\JobEntryData\\TestID.csv"; let JEDriver = DDT.CSVDriver(csvPath); var i = 1; ih.RunInnovationsProgram("JobEntry.exe"); ih.LoginToInnovations("JobEntry","Ocuco",""); while (!JEDriver.EOF()) { Log.Message("******************** Test run number " + i + " has Started... ********************************") iv.LoadUIVariables(i); SetUIVariables(); PopulateIDPage(); PopulateFramePage(); PopulateLensesPage(); PopulateRxPage(); PopulateExtrasPage(); //PopulateBlanksPage(); PopulateInvoicePage(); Log.Message("^^^^^^^^^^^^^^^^^^^^^^^^^^^ Test run number " + i + " has finished. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); //Indexes to next line of data sources i++; //Indexes to next line in id file JEDriver.Next(); } DDT.CloseDriver(JEDriver.Name); var testTime = aqConvert.FloatToStr(((aqPerformance.Value()/1000)/60)); Log.Message(aqString.Format("Minutes to complete tests: %.2f", testTime)); }
In each of the "populatexxx" functions are connections to external data csv's as data sources.
Since many tests can be run through this one script, with the data deciding how the UI acts, this is a single point of failure. If I were to make 20 tests, and one failed, I could do a cleanup and start on the next test.
It doesn't seem like I can do that here, because if the test fails, the test loses it's state and reports the error.
How can I handle errors using this technique?
Is my test setup fundementally flawed?
How does one create "individual" tests using DDT?
Thanks
Hi,
Not sure if I completely got your question... Also I am not quite sure what state you are talking about here: "if the test fails, the test loses it's state".
However, maybe this will help:
-- Your test project must be set up to not stop on error;
-- Each PopulateXXX() test function must return boolean as an indicator of whether or not the execution of the whole test can be continued;
-- Transform your main code to something like that:
var bResult; while (!JEDriver.EOF()) { Log.Message("******************** Test run number " + i + " has Started... ********************************") bResult = iv.LoadUIVariables(i); if (bResult) bResult = SetUIVariables(); if (bResult) bResult = PopulateIDPage(); ... Log.Message("^^^^^^^^^^^^^^^^^^^^^^^^^^^ Test run number " + i + " has finished. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); // you may consider whether or not to continue with the next data loop if (!bResult) break; //Indexes to next line of data sources i++; //Indexes to next line in id file JEDriver.Next(); } ...
Does this help?