Forum Discussion

charlesfradley's avatar
charlesfradley
Contributor
9 years ago

Eclipse / Maven integration of Soapui free edition ?

Greetings,

 

I am trying to integrate SoapUI [free edition] into the Eclipse IDE to launch tests from there, and via Maven projects.

We would like to integrate SoapUI into Maven so we can perform continuous integration regression tests.


Most of the resources I have found, e.g. the docs on the Smartbear site, seem to assume that I have the pro edition of SoapUI.


Is it possible to integrate the free edition of SoapUI into Eclipse and/or Maven ?


Or will we have to buy the pro edition, or another product ?

  • workpeter's avatar
    workpeter
    Occasional Contributor

    OK well i managed to solve this issue. The key thing i realised is that if you want to control SOAPUI programmically within java you need to rely on numerous lib files which you can get from the lib directory of  ready API, but they arent available in their entirety via any maven repository. Oh and By programmically , i mean having the ability to run SOAPUI within specific methods rather than just executing blindly via the POM file. This is important to me because I use BDD framework (cucumber) and so my test execution needs to occur within specific method annotations. 

     

    Now the easy solution would be not to use Maven and just kick off my tests directly using testNG or junit, therefore leveraging local the SOAPUI external lib files, however my overall testing approach/architecture is build on Maven, so I needed to use it. 

     

    To solve, I essentially copied all the SOAP lib files into the maven local repository and created a dependency on each one within the POM file. Considering there are around 300 lib files, this was only possible using a batch script.  

    Attached are two files which you guys can use to achieve same result. 

     

    create_soapui_repo.bat will look in C:\Program Files\SmartBear\ReadyAPI-2.2.0\lib and put each of these lib files in your local Maven repo. Review the code first then when happy, you can remove the .txt and run it. 

     

    POM.xml is a prebuilt POM file with all the dependencies for each jar file. 

     

    F.Y.I i built this quickly using string manipulation code so a few of the version references are out. However it will still work due to the folder structure matching in the repo. 

    • rupert_anderson's avatar
      rupert_anderson
      Valued Contributor

      Hi workpeter,

       

      Sorry for not replaying sooner, I was out all day yesterday!

       

      Good question, answer and well done sharing it with the community! :smileywink:

       

      The solution that you are describing is very much in line with challenges I have experienced, although I tended to favour Gradle and Groovy (with Grab to resolve dependencies), rather than Maven. Managing the rather large Soapui lib requirements is not only a challenge when running SoapUI as you are, but also when you need to Groovy script in some of the more modern 3rd party client libs e.g. newer Selenium / AWS java API (where they often have newer versions of some of the same libs as SoapUI has resulting in classpath issues, I sometimes found myself have to do dependency gymnastics to get them to work). I remember these 3 being an issue for example:

       

          exclude(module: 'jms')
             exclude(module: 'jtidy' )
             exclude(module: 'cajo' )
      

      I have been mostly a spectator in the Soapui community for more than a year now, as I have shifted job role more into DevOps from application development, but questions like this make me remember all the improvements / feature requests I wanted to contribute to improve some of these catches. It wouldn't take a lot to make some big improvements. Nice to see you and others are contributing quality posts!

       

      Thanks,

      Rupert

      • MartinSpamer's avatar
        MartinSpamer
        Frequent Contributor

        While copying the libs, or adding them to the Eclipse project as a library will work, this will probably not be easily deployable on a CI server.  I think the correct solution is to make the jars available in your maven repos. I solved this as following:

         

        1. Cloning the SOAPUI project from GitHub locally.
        2. To make available on Jenkins or your CI, add a job build to your teams CI maven repo.
        3. Add the following dependencies to the test projects POM.XML

         

         <dependencies>
        <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy-json</artifactId>
        <version>2.5.4</version>
        <type>pom</type>
        </dependency>

        <dependency>
        <groupId>com.smartbear.soapui</groupId>
        <artifactId>soapui</artifactId>
        <version>5.0.0</version>
        </dependency>
        </dependencies>

         You will probably find it useful to create two or three maven build profiles for:

        • java for cucumber-jvm,
        • groovy for to develop groovy scripts inside Eclipse
        • automation to test against the actual project.

        Apache Maven : an introduction to maven profiles

        I prefer to keep my automation project completely seperate from the SUT project, but you if you prefer otherwise you could have a seperate profile to build that as well.

         

  • rupert_anderson's avatar
    rupert_anderson
    Valued Contributor

    Hi,

     

    The free SoapUI Open Source should be able to run fine via Maven:

     

    https://www.soapui.org/test-automation/maven/maven-2-x.html

     

    You often see pro-only etc on the SoapUI wiki, but there are two versions of the Maven SoapUI plugin. Here is a very simple snippet for version 5.0.0:

    ...
    <pluginRepositories>
               <pluginRepository>
                 <id>SmartBearPluginRepository</id>
                    <url>http://www.soapui.org/repository/maven2/</url>
               </pluginRepository>
    </pluginRepositories>
      <build>
          <plugins>
              <plugin>
                  <groupId>com.smartbear.soapui</groupId>
                  <artifactId>soapui-maven-plugin</artifactId>
                  <version>5.0.0</version>
                  <executions>
                      <execution>
                          <phase>test</phase>
    							<goals>
        							<goal>test</goal>
                				</goals>
                				<configuration>                         
                				<projectFile>src/test/resources/SOAPTest-soapui-project.xml</projectFile>
                               </configuration>
                           </execution>
                       </executions>
                   </plugin>
               </plugins>
    </build>
    ...

    In terms of running SoapUI from within Eclipse, how exactly did you mean? Once the SoapUI dependencies are present, it can be quite easily run via Java, Groovy, Gradle, Maven..

     

    In general, most things are possible in SoapUI O/S, sometimes with a little extra effort/thought and often with the help of Groovy scripts etc! :-) 

     

    Regards,

    Rupert

    • workpeter's avatar
      workpeter
      Occasional Contributor

      Hi Rupert, 

       

      Thank you, I have read all your posts on this thread. I have a question if i may. 

      I am attempting to run SOAPUI project via eclipse and Maven. I can see you've posted a POM will which contains the execution configuration, however id prefer to control the execution programmatically, so i can incorporate within my BDD solution. 

       

       

      Whilst it is possible to do so using the following code and i am having an issue:

       

      import com.smartbear.ready.cmd.runner.SoapUITestCaseRunner;

       

      SoapUITestCaseRunner runner = new SoapUITestCaseRunner();
      runner.setProjectFile(projectFilePath);
      runner.run();

       

      The code above executes if i run the project as an TestNG project ( i included the SOAPUI lib files to project), however when I run it as a Maven execution, then i get the following error:

       

      java.lang.NoClassDefFoundError: com/smartbear/ready/cmd/runner/SoapUITestCaseRunner

       

      I thought it should work since i did include the relevent SOAPUI references within the POM file (the only thing i removed was the execution details. Bellow is my POM file. 

       

      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      	<modelVersion>4.0.0</modelVersion>
      	<groupId>SOAPUI</groupId>
      	<artifactId>SOAPUI</artifactId>
      	<version>0.0.1-SNAPSHOT</version>
      
      	<dependencies>
      		<dependency>
      			<groupId>org.testng</groupId>
      			<artifactId>testng</artifactId>
      			<version>6.14.2</version>
      			<scope>test</scope>
      		</dependency>
      	</dependencies>
      
      	<pluginRepositories>
      		<pluginRepository>
      			<id>SmartBearPluginRepository</id>
      			<url>http://www.soapui.org/repository/maven2/</url>
      		</pluginRepository>
      
      
      
      	</pluginRepositories>
      	<build>
      		<plugins>
      		
      		
      			<plugin>
      				<groupId>com.smartbear.soapui</groupId>
      				<artifactId>soapui-maven-plugin</artifactId>
      				<version>5.0.0</version>
      <!-- 				<executions> -->
      <!-- 					<execution> -->
      <!-- 						<phase>test</phase> -->
      <!-- 						<goals> -->
      <!-- 							<goal>test</goal> -->
      <!-- 						</goals> -->
      <!-- 						<configuration> -->
      <!-- 							<projectFile>src/test/resources/REST-Project-2-soapui-project.xml</projectFile> -->
      <!-- 						</configuration>				 -->
      <!-- 					</execution> -->
      <!-- 				</executions> -->
      			</plugin>
      
      
      			<plugin>
      				<groupId>org.apache.maven.plugins</groupId>
      				<artifactId>maven-surefire-plugin</artifactId>
      				<version>2.21.0</version>
      				<configuration>
      					<suiteXmlFiles>
      						<suiteXmlFile>testng.xml</suiteXmlFile>
      					</suiteXmlFiles>
      					<!-- <forkCount>3</forkCount> -->
      					<!-- <reuseForks>true</reuseForks> -->
      				</configuration>
      			</plugin>
      		</plugins>
      	</build>
      </project>
      
      
      
      
      
      
      
      
      
      

       

       i was thinking the SoapUITestCaseRunner class is missing, and i need to update my POM dependencies. However that aside, i think this is more an issue with Maven not picking up the SOAPUI jar files i've added as external library within the eclipse project. 

       

      Any ideas?

      • charlesfradley's avatar
        charlesfradley
        Contributor

         

        Hi Rupert and co,

         

        I have added the above to my POM file, but I am still getting an import failure:

         

        import com.eviware.SoapUI.tools.SoapUITestCaseRunner;   [cannot be resolved]

         

        Do I need to add a jar file to the project ?  Or is maven supposed to take care of that ?

         

        Thanks,

         

        CFR.

         

        My POM now looks like this:

         

        <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>SoapUI_First</groupId>
        <artifactId>SoapUI_First</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <pluginRepositories>
        <pluginRepository>
        <id>SmartBearPluginRepository</id>
        <url>http://www.soapui.org/repository/maven2/</url>
        </pluginRepository>
        </pluginRepositories>
        <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
        <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.3</version>
        <configuration>
        <source>1.8</source>
        <target>1.8</target>
        </configuration>
        </plugin>
        <plugin>
        <groupId>com.smartbear.soapui</groupId>
        <artifactId>soapui-maven-plugin</artifactId>
        <version>5.0.0</version>
        <executions>
        <execution>
        <phase>test
        </phase>
        <goals>
        <goal>test
        </goal>
        </goals>
        <configuration>
        <projectFile>src/test/resources/SOAPTest-soapui-project.xml</projectFile>
        </configuration>
        </execution>
        </executions>
        </plugin>
        </plugins>
        </build>
        </project>