cancel
Showing results for 
Search instead for 
Did you mean: 

Identify Security tests in a TestRunListener.afterRun listener

SOLVED
New Contributor

Identify Security tests in a TestRunListener.afterRun listener

I want to handle afterRun events for normal tests and security tests separately. I tried implementing the below two listeners. 

TestRunListener.afterRun

SecurityTestRunListener.afterRun

I expected these to be mutually exclusive. However, the TestRunListener.afterRun seems to get triggered at the end of Security tests as well. I tried identifying security tests with the name of the test case. But the below statement in the TestRunListener.afterRun gives the name of the functional test even at the end of the security test. 

log.info(testRunner.testCase.getName())

I expected to get something like 'SecurityTest 10'. But received 'GETVersion200' (name of my functional test). 

How do I differentiate a functional test run from a security test run in the TestRunListener.afterRun listener?

1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: Identify Security tests in a TestRunListener.afterRun listener

Thanks for posting the additional information, @hariSoapUI.

It looks like this request is specific to your environment. Could you please contact our Support Team to continue investigating this behavior? You can contact them here:

https://support.smartbear.com/message/?prod=ReadyAPI

---------
Tanya Gorbunova
SmartBear Community Manager

Join the September Hub-bub to show off, learn and win
3 REPLIES 3
Moderator

Re: Identify Security tests in a TestRunListener.afterRun listener

Hi @hariSoapUI,

 

I have contacted one of our support engineers who could describe the idea of the approach that could help you:

 

You can use the Target field in the Events dialog to make it possible to call an event only for the test items specified in Target. You can specify a regular expression there that would check the test item name - for example, it could check whether the name contains the “security” word. If there is no such word in the name, the event will be executed, or it will not be, otherwise.

 

Please let us know whether this helps.


Olga Terentieva
SmartBear Assistant Community Manager

New Contributor

Re: Identify Security tests in a TestRunListener.afterRun listener

 

Hi Olga, 

The use case I have is a little different from what you stated. 

End of Functional test run -> Only TestRunListener.afterRun should be invoked -> This works

End of Security test Run -> Only SecurityTestRunListener.afterRun should be invoked. -> BothTestRunListener.afterRun and SecurityTestRunListener.afterRun are getting invoked. 

 

I added the target       ^((?!Security).)*$      to the TestRunListener.afterRun and ran the Security test named SecurityTest 10

Here are the logs at the end of a Security test. It runs the TestRunListener also. 

 

  • Wed Aug 21 14:14:08 MDT 2019: INFO: #######Normal Test Run Listener script#######
  • Wed Aug 21 14:14:08 MDT 2019: INFO: Test case name : GETVersion200 Test Suite Name : Version
  • Wed Aug 21 14:14:08 MDT 2019: INFO: Time Taken: 6079 Run Status : PASS Status: Passed
  • Wed Aug 21 14:14:10 MDT 2019: INFO: #######Security Test Run Listener script#######
  • Wed Aug 21 14:14:10 MDT 2019: INFO: Name : GETVersion200
  • Wed Aug 21 14:14:10 MDT 2019: INFO: Test case name : GETVersion200 Test Suite Name : Version
  • Wed Aug 21 14:14:10 MDT 2019: INFO: Time Taken: 6079 Run Status : PASS Status: Passed

 

Community Manager

Re: Identify Security tests in a TestRunListener.afterRun listener

Thanks for posting the additional information, @hariSoapUI.

It looks like this request is specific to your environment. Could you please contact our Support Team to continue investigating this behavior? You can contact them here:

https://support.smartbear.com/message/?prod=ReadyAPI

---------
Tanya Gorbunova
SmartBear Community Manager

Join the September Hub-bub to show off, learn and win
New Here?
Join us and watch the welcome video:
Watch the New Interview
7Mistakes
Join the exciting event
SeptemberHubBub
Top Kudoed Authors
Join the September Hub-bub to show off, learn and win