Hi all I am facing a problem with StringBuilder. While automating, I will assign the value of testfailed to a StringBuilder as
private StringBuilder testFailed = new StringBuilder();
public void Test1()
{
testFailed = SomeTest();
}
public void Test2()
{
testFailed = null;
//testFailed = testFailed.Clear();
//testFailed = new StringBuilder();
testFailed = someTest1();
}
When ever first test fails, the testFailed StringBuilder will append the next test result or if test passes then testFailed string will display the testFailed b result value. As I used commented methods and tried it didn’t work for that. Let me know any other ways. Thanks in advance.
I am not sure what you are trying to achieve from this. But I am guessing you want to aggregate the errors from various tests that you are running. If thats the case you dont need to reassign the
StringBuilderclass just use a single instance and useAppendson it and your test will return string as a result.Eg.
I dont know why you are taking this approach, but to each his own. I would also suggest you take a look at NUnit.