Skip to main content

Posts

Showing posts with the label soapUI

Data driven testing in SoapUI using groovy script with excel file

SoapUI Pro has a feature to read data from external files like: excel, csv etc. But SoapUI does not provide such feature to read data from excel file. So for reading data from excel file in SoapUI, we need to write some code in groovy script. I this post I will show you, how to read data from excel file.I am using poi jar files to read data from excel file in groovy, download following jar files and put into SoapUI lib folder. poi-3.8-beta5-20111217.jar poi-examples-3.8-beta5-20111217.jar poi-excelant-3.8-beta5-20111217.jar poi-ooxml-3.8-beta5-20111217.jar poi-ooxml-schemas-3.8-beta5-20111217.jar poi-scratchpad-3.8-beta5-20111217.jar  dom4j-1.6.1.jar In this post, I have created a SoapUI project for “ConversionRate“ API, and created a test case and teststep with name “ConversionRate”. So here I need to run this test for the set of data, where data is in external excel file. I have created a “ReadXLSFile” groovy step and write below code to read data from “Book1.xls...

Data driven testing in SoapUI from csv file

I will show you how to execute SoapUI test for a set of values. For this I have put all data in csv file. I write groovy scripts for reading data from csv and executing the test steps. Below is the groovy script for reading data from “TestData.csv” file where I put all user credentials. def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context) def csvFilePath = "E:\\TestData.csv" context.fileReader = new BufferedReader(new FileReader(csvFilePath)) rowsData = context.fileReader.readLines() int rowsize = rowsData.size() for(int i =0;  I < rowsize;  i++) {     rowdata = rowsData[i]     String[] data = rowdata.split(",")     log.info data[1]         groovyUtils.setPropertyValue("Login", "UserName", data[0])     groovyUtils.setPropertyValue("Login", "Pass", data[1])     testRunner.runTestStepByName( "Login")   } ...

Reading data from text file in SoapUI using groovy script

How to read data from text file in SoapUI. SoapUI Pro has some advance feature which is not in SaopUI as data fetching from external sources so in SoapUI we use Groovy script for that. Following are the peace of groovy script code for reading data from text file. 1. Reading all data from text file. //reading all txt file at once File file = new File("E://TestData.txt") fileContent = file.getText()                  log.info fileContent 2. Reading data line by line from text file. //reading text line by line File file1 = new File(" E://TestData.txt ") List textLine = file1.readLines() log.info textLine 3. Reading data randomly of any line from text file. //reading text randon line number File file2 = new File(" E://TestData.txt ") List textLine2 = file2.readLines() rowIndex  =  Math.abs(new Random().nextInt() % 4 + 1) log.info textLine2[...

Installation of SoapUI plugin into Eclipse.

Following are the steps to install soapui plug-in into eclipse. 1. Open Eclipse IDE and goto “Help” menu and click on “Install New Software” 2. Click on add button you should see like below window. 3. Enter some text into “name” field as “SoapUI“ and enter url http://www.soapui.org/eclipse/update into “Location” field. 4. Click on “OK” button, you should see below screen and soapUI will display. 5. Click on soapui check box and click next button. 6. Click on Next button again you should see license agreement window. 7. Accept term and license agreement and click on next button. you should see installation start. 8. Accept term and license agreement and click on next button. 9. During installation security warning popup window displayed, click on “OK” button of security warning. 10. Restart Eclipse to take effect on the new plugin installation 11. In eclipse goto “window>>Open Perspective>>Other” on top menu bar and select soapUI. You should s...

Execution of SoapUI project using Junit

In this post I am going to show you how to execute SoapUI project using Junit. SoapUI provide testrunner class name “SoapUITestCaseRunner” which can be used to run soapui test using java class, maven or ant build tool. We create object of this class in java file and call the run function to execute soapui project. Steps to create Junit test for soap ui project: 1. Chose any IDE as eclipse or NetBean 2. Add “soapui-4.5.1.jar” from soapui bin folder and soapui lid folder as library to class path of your project (eclipse). 3. Use “SoapUITestCaseRunner” class object to run soapui project as mentioned in below code: //import classes import org.junit.Test; import com.eviware.soapui.tools.SoapUITestCaseRunner; //Junit test method @Test public void testSoapUI() {     //initialize  SoapUITestCaseRunner class object     SoapUITestCaseRunner soapUITestCaseRunner = new SoapUITestCaseRunner();         //set...

Performance testing using soapUI

I would like to show you performance testing of webservices using soap ui. Performance testing of web services is not just running SOAP or XML messages in a loop to run the service. It should be a well-planned activity which must be aligned with the performance expectations of the overall service-oriented solution.  You can run multiple type of performance test such as SOAP , JSON, XML format messaging through a single interface SoapUI allows users to configure various load testing options such as delays in between threads to simulate real-world use cases and run tests in burst mode to stress test services. How to create Load Test:  Just go to Navigation bar of soapUI click on your create soaui project and expand test case. Right click on “load test” options, enter load test name on opened window and click on OK button. Your created load test window looks like as below. As in above screenshot have two soap ui test method “login” and “Register” both methods are automatic...

Command line execution of soapUI project

We run SoapUI project using SoapUI GUI interface.  SoapUI also provide set off batch files to execute soapUI tests from command line without using SoapUI GUI interface.  Following are the runner scripts inside installed SoapUI bin folder. 1.  testrunner.bat :  this is use to run functional test using command line. 2.  loadtestrunner.bat:  This is used to run soapui load testing using command line. 3.  mockservicerunner.bat :  This is used to run soapui mock services using command line. 4.  toolrunner.bat:  This is used to launch soapui tools. 5.  securitytestrunner.bat:  This command is used to run security tests Note:  setup soaui bin folder path into your system variable path. Command Line soapui tests execution: 1. Open command prompt and got to your created soapui project. 2. Run command > testrunner {SoapProjectName}.xml 3. After running test you should see some text file is generated in root. 4. We can r...

Important SoapUI functions in groovy script

Important soapui functions which are basically used in soap ui groovy scripts. 1. Following functions are used to read properties in soapui project. projectPropertyValue = context.expand( '${#Project#Test}') projectPropertyValue = context.expand( '${#TestCase#Test}') projectPropertyValue = context.expand( '${#TestSuite#Test}' I have create three properties with name "Test" at project, testsuite and test case level. Using above code we can read values in groovy scripts and can be use where needed. 2. Setting properties value test case. def myTestCase = context.testCase myTestCase.setPropertyValue("Name", “Value”) 3. Reading end url value of any test steps. Replace your test step name with “TestStepName” EndPointUrl  = context.getProperty("TestStepName","Endpoint") 4. Setting parameter value of test steps. Replace you test step name, parameter name and value with “TestStepName”, “dataSet” and “v...

Script assertion in Soap UI for WSDL API methods

In this post I will show you how to add script assertion in SoapUI response of wsdl api test methods. Here I have an example of CurrencyConvertor, I created a SoapUI project and added test case for this method as you can see in below window. Now here in response body I will add assertion that verify the “ConversionRateResult” value is always 104 for given input value. Steps to add script assertion: Click on “Assertions” button at bottom of left side. Clicks add icon as point 1 mentioned on below image. Chose script option as mentioned point 2. Click script assertion as mentioned point 3. Click add button as mentioned point 4. You can see a window opened where you can add your script assertion code.  When I execute “CurrencyConvertor” with input parameter values “USD”, “ALL” got below response message   Approach to write script assertion for above response: 1. Import xml holder class at first line and create XmlHolder object. imp...