My project has a shared test-as-step that each of my other tests call. This test-as-step has the following override that is attempting to use properties of the testresult parent/calling test name to add to the custom log we've created:
public override void OnAfterTestCompleted(TestResult result)
{
base.OnAfterTestCompleted(result);
string parentName = Convert.ToString(result.Parent.Name); //line 103
string parentId = Convert.ToString(result.Parent.Id);
string parentRootName = Convert.ToString(result.Parent.RootName);
string fileName = Convert.ToString(result.Parent.FileName);
\\custom code to write to the log
}
Each line in the above override that references the testresult.parent.* properties test trigger the following error:
System.NullReferenceException: Object reference not set to an instance of an object.
at CIS.TestStudio.WebAccess.Shared.Handler.OnAfterTestCompleted(TestResult result) in c:\tfs\CoreCM\Root\CIS.TestStudio.WebAccess\Shared\Handler.tstest.cs:line 103
at ArtOfTest.WebAii.Design.Execution.ExecutionEngine.InternalExecuteTestIteration(Object codeBehindInstance, Boolean isDataDriven)
at ArtOfTest.WebAii.Design.Execution.ExecutionEngine.ExecuteDataDrivenTest(Test test, BaseWebAiiTest codeInstance)
at ArtOfTest.WebAii.Design.Execution.ExecutionEngine.InternalExecuteTest(Test test, TestResult initializationResult)
at ArtOfTest.WebAii.Design.Execution.ExecutionEngine.ExecuteTestInCurrentContext(Test test)
If this is not the correct way to access the name of the parent/calling test properties, is there a better way to do so through code?
public override void OnAfterTestCompleted(TestResult result)
{
base.OnAfterTestCompleted(result);
string parentName = Convert.ToString(result.Parent.Name); //line 103
string parentId = Convert.ToString(result.Parent.Id);
string parentRootName = Convert.ToString(result.Parent.RootName);
string fileName = Convert.ToString(result.Parent.FileName);
\\custom code to write to the log
}
Each line in the above override that references the testresult.parent.* properties test trigger the following error:
System.NullReferenceException: Object reference not set to an instance of an object.
at CIS.TestStudio.WebAccess.Shared.Handler.OnAfterTestCompleted(TestResult result) in c:\tfs\CoreCM\Root\CIS.TestStudio.WebAccess\Shared\Handler.tstest.cs:line 103
at ArtOfTest.WebAii.Design.Execution.ExecutionEngine.InternalExecuteTestIteration(Object codeBehindInstance, Boolean isDataDriven)
at ArtOfTest.WebAii.Design.Execution.ExecutionEngine.ExecuteDataDrivenTest(Test test, BaseWebAiiTest codeInstance)
at ArtOfTest.WebAii.Design.Execution.ExecutionEngine.InternalExecuteTest(Test test, TestResult initializationResult)
at ArtOfTest.WebAii.Design.Execution.ExecutionEngine.ExecuteTestInCurrentContext(Test test)
If this is not the correct way to access the name of the parent/calling test properties, is there a better way to do so through code?