How can I get output from a non-UI test to the Test Results UI?
My scenario is this, currently contained in one coded Web Test:
1) post to an ISAPI DLL, parse out fields from response
2) insert step 1 parsed-info into DB, start a windows service, wait for it to finish
After #2 finishes, I'd like to have the resultant (multi-line) string displayed in the Test Results UI. In order to accomplish that, I throw a generic Exception (at the end of the Web Test) that has my string in it, which gets shown in the UI like I want, but also fails the test.Note that this breaks the scenario where there's a thrid step that uses info from step #2, since it would be skipped when the exception is thrown.
Question: Can I get my (non-Web Test) result-string into the UI without failing the test?
NOTE: It would probably make more sense to make this as an Ordered Test that contains a Web Test for #1, and a Unit Test for #2. But when I do that my 'WebTestPlugin' class isn't persisted across each test, it gets re-instantiated. So maybe my question should really be 'how can I pass info from a Web Test to an Unit Test?'
Thanks in advance,
m
[1210 byte] By [
mikul] at [2007-12-20]
Hi there. I'm not sure I really understand your question.
If you want to know how to log extra data, even when a test passes... as far as I know, the only way to get a string into the Error Message part of a test, you have to fail it in some way. On way is to throw an exception. The other is it call Assert.Fail, or an equivalent, with a message. If you want to log some extra data, then you can get that by writing a message to the console. In C#, we write Console.WriteLine("message"). You'll find that info in the Test Result Details.
Cheers,
David
Thanks for the response, David, but I don't want to throw an exception and fail the test, b/c the test passed, as I stated in the original post. I'm already throwing the Exception to get the info to the UI, but that's the problem I'm having.
In a Web Test, writing to the Console doesn't seem to do anything, which I would expect (I'm using a Web Test currently); but it looks like my second step would be better represented as a Generic Test anyway, in which case writing to the Console would actually be useful.
Even more useful is the 'Summary Results File' for Generic Tests which is exactly what I need. http://msdn2.microsoft.com/en-us/library/ms243174(VS.80).aspx