Running the tests through Maven

We currently have a test that works fine in IntelliJ, but we haven't put any configuration in our POM file yet to enable us to run this test through Maven. Let's create a Maven profile that will allow us to do that. First of all, we need to add a property to define our maven-failsafe-plugin version:

<maven-failsafe-plugin.version>2.21.0</maven-failsafe-plugin.version>

Then we need to add a new profile:

<profiles>
<profile>
<id>appiumAlreadyRunning</id>
<activation>
<property>
<name>!invokeAppium</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-failsafe-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<appiumServerLocation>${appiumServerURL}
</appiumServerLocation>
<enableDebugMode>${enableDebugMode}
</enableDebugMode>

<screenshotDirectory>
${project.build.directory}
/screenshots</screenshotDirectory>
<remoteDriver>${remote}</remoteDriver>
<appiumConfig>${appiumConfig}
</appiumConfig>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

This will look very similar to maven-failsafe-plugin that we have set up in our Selenium framework. What is slightly different is the way we are using <activation> this time. We are looking to see if a property called invokeAppium has been set. If it hasn't, we run this profile. This means that by default this profile will always run. We will explain why we have used activation in this way later on in this chapter. For now, we can try running our tests through Maven.

First of all, we will need to start up our Appium server (if you don't still have it running). Then on the command line you will need to type:

mvn clean verify

You should see the Maven build start up and it will connect to the Appium server that you have started. It will then successfully complete the tests. This is great, if you are happy starting and stopping an Appium server by yourself, but it's not yet a system that does everything for you. We can make this better.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.126.5