ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 17.04.2021
Просмотров: 1377
Скачиваний: 2

51
<projectFile>simple-test-soapui-project.xml</
projectFile>
</configuration>
</plugin>
</plugins>
This will specify that we want to use a plugin called maven-soapui-plu-
gin and that we want to use version 4.5.1 of the plugin.
The project we want to execute is specified in the configuration section
and it is called simple-test-soapui-project.xml.
You can specify more things, but this is a small start with just a few mov-
ing parts.
The next step would be to execute a test.
Execute a test from Maven
Maven is a command line tool that is executed with the command
mvn
You want to specify at least one goal that Maven should execute. The
simplest possible could be
mvn validate
It will validate that the format of your pom is correct.

52
To actually execute the test we specified above, run this instead:
mvn eviware:maven-soapui-plugin:test
We specify that we want to execute the SoapUI plugin and the goal test.
The plugin has other goals that you could use. Executing load test is
one of them.
These were just a few snippets. Let’s put them in context in a complete
example.
Properties
You can define properties in your test. You need to add a section called
projectProperties in the configuration section. Then add the values you
want as name value pairs.
<configuration>
<projectFile>simple-test-soapui-project.xml</project-
File>
<projectProperties>
<value>message=Hello World!</value>
</projectProperties>
</configuration>
There should not be any space after the equals sign. It would place a
space in front of your value. That could be a subtle bug that you would
like to avoid.

53
A complete example
A small example can look like this:
<?xml version=”1.0” encoding=”UTF-8”?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.smartbear</groupId>
<artifactId>soapui-example</artifactId>
<version>1.0-SNAPSHOT</version>
<pluginRepositories>
<pluginRepository>
<id>eviwarePluginRepository</id>
<url>http://www.soapui.org/repository/maven2/</
url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>eviware</groupId>
<artifactId>maven-soapui-pro-plugin</arti-
factId>
<version>4.5.1</version>
<configuration>
<projectFile>simple-test-soapui-project.
xml</projectFile>
</configuration>
</plugin>
</plugins>
</build>
</project>

54
I have defined the necessary plugin repository and configured the
soapui plugin. I used the pro version here. If you would like to do the
same thing for SoapUI, then use the plugin called maven-soapui-plugin.
To execute this example, run Maven like this:
mvn eviware:maven-soapui-pro-plugin:test
from a command line prompt.
You can define properties that will be set from the pom and you can
run the tests as an integrated part of the Maven build. That is more of a
Maven discussion than a SoapUI discussion, so I will leave that out to
minimize the number of moving parts.
More details
The Maven plugin can be used to do more than what I described here.
The details can be found at the SoapUIWeb site.
10
Automate the execution
After creating your SoapUI functional tests with test suites and connect-
ing SoapUI tests to your build tool, it is time to execute them, as soon as
a change has occurred.
There are many different build tools available. One popular tool is Jen-
kins.11. Jenkins will be able to listen for a change on a url and kick off a
test job. This would make it possible for you to start testing as soon as
there is something new to test.
All build servers handle Maven projects out of the box, so setting up a
build that executes SoapUI tests is just a matter of setting up a Maven
build. Describing that is, however, out of scope here.
10 http://www.soapui.org/Test-Automation/maven-2x.html
11 http://jenkins-ci.org/

55
Conclusion
You should now be able to verify and test APIs using a tool like SoapUI.
Your chances of securing the delivery of high quality APIs will be drasti-
cally improved, compared to when testing the services using your own,
homegrown API clients. You will save a lot of time and be able to focus
on the real problem, testing, instead of the problem of creating your test
tool.
will give you additional benefits. You will be able to
save even more time, and therefore money, by using the built-in fea-
tures of SoapUI Pro that are specifically targeted on speeding up com-
mon tasks. Reporting, Data driven testing and simplified test creation
are just three examples.