问题
How I can add my source code ( java code ) to project SoapUI running by maven? I wrote own assertion class and check response in this class. First i made dir ext and put there .jar file. Now I want do the same, but with source code.
回答1:
By adding a jar in the \ext
folder you made the compiled class available to SoapUI test runner.
Instead of that you could include your code as a maven module in your project and add it as dependency. Your Java code should be a maven project for this to work.
A common approach is to create a "modules" directory in your project's root and add your java code in a subdirectory there, let's call it "assertion_module":
<root>
| - soapui-project.xml
| - pom.xml
| - modules
| - assertion_module
| - src
| - pom.xml
The pom.xml in the folder should have the necessary properties set, like below (sample values):
<groupId>assertion_module</groupId>
<artifactId>assertion_module</artifactId>
<name>assertion_module</name>
<version>0.1</version>
In you master pom.xml
, i.e. the one that you use to run the SoapUI tests declare your assertion module, adding the following:
<modules>
<module>modules/assertion_module</module>
</modules>
In the soapui plugin section of this pom add the necessary dependency section:
<plugin>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui-maven-plugin</artifactId>
<version>5.1.2</version>
<dependencies>
<dependency>
<groupId>assertion_module</groupId>
<artifactId>assertion_module</artifactId>
<version>0.1</version>
</dependency>
</dependencies>
...
</plugin>
Now when you run your tests, the assertion_module will be compiled and be available to SoapUI test runner.
With this you no longer need to add the compiled jar in the \ext
folder, although you still need to have it in the <SoapUI_installtion_directory>\bin\ext
.
来源:https://stackoverflow.com/questions/30320647/source-code-in-soapui-maven