Adding ‘Events’ in SoapUI projects
- khyati sehgal
- Jul 22, 2014
- 2 min read
SoapUi provides a wide range of features, and via these capabilities, we can not only test our web-services as a whole but also we can implement multiple functions to test an application’s services. Today I will discuss ‘Events’ in SoapUi so let’s get started.
What are events in SoapUI?
Events as the name suggest comes in SoapUi with a motive. We can leverage this feature for testing various web services that require some pre-steps for completion. Let us understand this with an example. Let say we have a test case in which we have to test a scenario. This scenario is dependent on various test steps placed in this test case.
For instance, the test is to verify a search web service where-in we have to verify that search is working or not. Now for testing this we need to get into the application. And this web site takes user credentials for logging into the application.
So what we can do in SoapUI is we can add an event for beforeTestCase which will work for each test case. And that is how we can make reusable test steps and get rid of writing similar tests again and again.
Another test case would be if Application under test is such that we have to clear database before every test case, then what we can do is we can make a beforeTestCase which will be responsible for clearing database and setting up the system.
And we can apply a similar thing to many other test cases.
Do You Know?
This is something very similar to what we have in JUnit and TestNG methods. Where-in we have different functions like BeforeTest, BeforeClass, AfterTest, etc apart from Test, which is specifically for writing a test cases.
And we can leverage these in-built functions for further use.
How to make events in SoapUI?
Open SoapUI PRO.
Make a new project or just click on an existing project.
You will get multiple options like Overview, TestSuite, JDBC Connections, etc. One of the tabs would be of Events. Click on this tab.
Click on the (+) icon. This icon will help you add new events for the selected project.

Once clicked, you will get a list where-in you can select the type of event you want to add to your project.
What type of events SoapUI PRO provides?
SoapUI provides a quite-a-lot long list of the events. This depends on the type of test case you are dealing with. For example, if you want to add an event in LoadTest then you can select the events having naming convention as LoadTestRunListener.XXXXX
For simple tests which are made out of rest services, just for verifications, you can use TestSuiteRunListener.beforeTestCase, TestSuiteRunListener.afterTestCase, etc.

The best part is you can loggers to these methods, for example, if you want to add a note before/after each test run completion then you can use them. For example, the run of TestCase1 is Completed Successfully, or TestCase1 failed, please check the logs for more info, etc.
Comments