This is a migrated thread and some comments may be shown as answers.

printing out testcase name, status, error message in coded step

1 Answer 91 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ali
Top achievements
Rank 1
Ali asked on 18 Apr 2012, 06:42 PM
Hello,
I am trying to follow the example here
http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/coded_steps.aspx 

I have a simple web test. 
At the end of the test, I need to write the testcase name, status, and message (in case of failure) to a remote mysql database. Instead of creating a separate coded step for each test case at the end of the recorded test steps, is it possible to create a generic coded step ?

Is there a way to reference the testcase name, status, message some how ?

For example: In NUnit, I can do the following in my test case teardown
console.write("name:" + TestContext.CurrentContext.Test.FullName)
console.write("status:" + TestContext.CurrentContext.Result.Status.ToString() ) 
console.write("message:" + 
TestExecutionContext.CurrentContext.CurrentResult.Message ) 

Thanks

Ali

1 Answer, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 18 Apr 2012, 08:32 PM
Hello Ali,

You have a couple options:
  • Use the OnAfterTestCompleted method to Execute Custom Script After the Test. This is on a per-test basis, however.
  • To have your desired code run after every test, without adding the code to each test individually, place it into the appropriate method in an Execution Extension. Once you compile and copy the DLL into the \Plugins folder, the code will execute before/after every test/test list executed.

See here for an example on how to reference the test results, and here for how to access a SQL database in code.

 Regards,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Ali
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Share this question
or