-1

I am currently running unit tests and I would like to log the results to the database. My tests are using specflow configured to convert the specs to MsTest.

My current method of determining test result:
* Check ScenarioContext.Current.TestError
* If it's null, the test passed
* If there's an error, check if the message contains "inconclusive" or "skipped" (this gets logged as inconclusive)
* Otherwise, the test gets logged as a failure

But this method seems really hacky to me. Is there a field somewhere that just tells me Fail Pass or Inconclusive, so I don't have to figure it out in a roundabout way?

GKS1
  • 291
  • 2
  • 12
  • 3
    if there's an error, that's not "inconclusive", that's a failure. inconclusive unit tests seem poorly designed. – DLeh Apr 17 '15 at 18:48
  • @DLeh Sorry the wording is kind of scary. I mean to say that the TestError object would contain a message that the test was inconclusive. This could happen because a webservice is down, or something like that, but isn't necessarily indicative of the test itself failing – GKS1 Apr 17 '15 at 18:54
  • unit tests shouldn't be calling web service calls. a unit test that is unreliable is useless. – DLeh Apr 17 '15 at 18:54
  • @DLeh for clarity, the tests are actually front end web tests using a combination of selenium, webservices, database calls, etc. For reasons detailed [here](http://stackoverflow.com/questions/22322596/selenium-error-the-http-request-to-the-remote-webdriver-timed-out-after-60-sec) tests don't always pass and sometimes need to be marked inconclusive so they can be re run later – GKS1 Apr 17 '15 at 19:08

1 Answers1

0

Are you certain this is the way you want to go? mstest and other runners already have options to output the results in xml format, which you could then archive.

/resultsfile:[ file name ]

https://msdn.microsoft.com/en-us/library/ms182489.aspx

bgiles
  • 1
  • It would be cool to have the test result available as soon as the test is done running for reporting purposes. Seems like an extra step to pull it from an XML file later. Thanks though – GKS1 Apr 21 '15 at 13:39