Get TestCase Name in Report

Best practices, code snippets for common functionality, examples, and guidelines.
JcNvG
Posts: 2
Joined: Tue Oct 16, 2018 8:42 am

Get TestCase Name in Report

Post by JcNvG » Tue Oct 16, 2018 9:17 am

Hey,

i want to get the name of the current TestCase into an e-Mail i send after finishing a testrun.

I tried TestReport.CurrentTestCaseActivity.TestCaseName, TestReport.CurrentTestModuleActivity.TestModuleName and several other commands, but the Mail-Logger fails to send emails if i try.

Is there an easy way to get the name of the current Testcase as a string?

Thank you in advance

JcNvG

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3925
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Get TestCase Name in Report

Post by odklizec » Tue Oct 16, 2018 10:09 am

Hi,

Email is usually sent as a last action in test suite, when the test suite is actually finished and there is no way to obtain current test case, because there is no longer "current" test case available.
What exactly do you want to achieve?
Could you please show us the structure of your test suite and location/implementation of email module?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

JcNvG
Posts: 2
Joined: Tue Oct 16, 2018 8:42 am

Re: Get TestCase Name in Report

Post by JcNvG » Tue Oct 16, 2018 12:45 pm

Thank you for the quick reply!
Email is usually sent as a last action in test suite, when the test suite is actually finished and there is no way to obtain current test case, because there is no longer "current" test case available.
This makes sense, yes.
After finnishing the test-runs, an email is sent, containing the Ranorex-Logfile as PDF. The email-body contains a short test-summary, which is structured like this at the moment:


Test-Name: [Name Test-Data] - Status: [success/fail] - ...
Test-Name: [Name Test-Data] - Status: [success/fail] - ...
Test-Name: [Name Test-Data] - Status: [success/fail] - ...
and so on...

The Suite contains severel Test-Cases. Every Test-Case is linked with an individual Excel-Data-Connector in which the Test-Data is stored.
I want to Add the Name of the Test-Case to the short summary in the email-body, so it should look like this:


Test-Case: Test-Case #1 - Test-Name: Data 1 - Status: success
Test-Case: Test-Case #1 - Test-Name: Data 2 - Status: failed
Test-Case: Test-Case #1 - Test-Name: Data 4 - Status: success
Test-Case: Test-Case #3 - Test-Name: Data 2 - Status: success

I think it should be possible because we already save the status and the name of the Test-Data.

I added a Screenshot of the TestSuite-structure. As seen, the MailLogger is user-code.

After some research i noticed, that there exists a method, which records the data used in a particular test-case. After finnishing the entire Test-Case, the recorded information is set into the mailbody.
I think i have to record the TestCase-Name inside of that "list" through that method.
Attachments
testsuite.jpg
testsuite.jpg (41.46 KiB) Viewed 54 times