The purpose of the below is to write a text file with the result of specific case. It works ok, when I specify the GetTestContainer to be equal to specific test case. (in the example it is "testercho"), but I would like to use the code as universal end recording through my test suite. I tried with "TestSuite.Current.Name, but it is not giving me the TestContainer name. What is the proper api call for this?
Thanks,
Lyubo.
Code: Select all
public static void Output2()
{
string result = "";
if(TestSuite.Current == null){
using (StreamWriter writer =
new StreamWriter("C:\\ovca\\null.txt"))
{
writer.WriteLine("test suite is null");
return;
}
}
//ITestContainer iCase = TestSuite.Current.GetTestContainer("testercho"); // It works ok, when Testcontainer is hardcoded
ITestContainer iCase = TestSuite.Current.GetTestContainer(TestSuite.Current.Name); // Here, I try with TestSuire current, but it is not the proper entry
int testrunID = 666;
if(iCase == null){
result = "iCase is Nullable";
}
else{
if(iCase.Status == Ranorex.Core.Reporting.ActivityStatus.Failed){
result = "Failed"; }
if(iCase.Status == Ranorex.Core.Reporting.ActivityStatus.Success){
result = "Passed"; }
}
using (StreamWriter writer =
new StreamWriter("C:\\ovca\\"+ TestSuite.Current.Name +".TXT"))
{
writer.WriteLine(testrunID);
writer.WriteLine(result);
}
}
}
}