Last week we have spoken about Xamarin Studio as an alternative for Visual Studio on a Mac OS.
This week we will see how we can run our webdriver tests on a Mac.
Requirements
Mono should be installed on the Mac for building and running tests from Xamarin solution.
Git should be installed on Mac for controlling source management systems.
NuGet.exe for restoring the packages used in the Xamarin solution.
NUnitConsole.exe used to run nunit tests.
Install Jenkins
First, we need to install Jenkins on the Mac OS. Jenkins can be installed in 3 ways:
- as a deamon
- inside a servlet
- as a normal process
Jenkins Plugins
In order to create a job for running webdriver nunit tests written in Xamarin Studio, integrated with git we need to intall the following jenkins plugins:
- Git Plugin
- NUnit plugin
- Xamarin Studio Tool Runner Plugin
Jenkins Configuration
Besides adding some plugins we need also to do some global configurations in Manage Jenkins --> Configure System.
Here, you'll need to set the path to git. In my case, the location is "/usr/local/git/bin/git".
Create the Job
Next, you'll have to create a new job. First you should made the settings for the source control management:
Create a step of type Execute shell that is used to restore the packages available in the solution in the jenkins workspace folder. Example of command to use:
mono --runtime=v4.0.30319 /Users/raluca/Desktop/Raluca/PINHelpers/Nuget/NuGet.exe restore /Users/raluca/.jenkins/jobs/macPinChromeMac/workspace/aut/Pin_Selenium_Testing-Xamarin/Pin_Selenium_Testing.sln
where /Users/raluca/Desktop/Raluca/PINHelpers/Nuget/NuGet.exe is the nuget location and
/Users/raluca/.jenkins/jobs/macPinChromeMac/workspace/aut/Pin_Selenium_Testing-Xamarin/Pin_Selenium_Testing.sln is the location of your project under source control
Next, we need to build the Xamarin solution. For this, having the appropriate plugin installed, we can create a step of type Build a Xamarin Studio solution using mdtool:
You need to provide the path to your .sln solution, starting from the jenkins workspace folder:
The following step is to run nunit tests. This is achievable by adding another Execute shell step that is using mono:
mono --runtime=v4.0.30319 /Users/raluca/Desktop/Raluca/PINHelpers/NUnit-2.6.4/bin/nunit-console.exe /Users/raluca/.jenkins/jobs/macPinChromeMac/workspace/aut/Pin_Selenium_Testing-Xamarin/PinTests/bin/Debug/PinTests.dll -xml:nunit-report.xml
where /Users/raluca/Desktop/Raluca/PINHelpers/NUnit-2.6.4/bin/nunit-console.exe is the path to nunitconsole executable
/Users/raluca/.jenkins/jobs/macPinChromeMac/workspace/aut/Pin_Selenium_Testing-Xamarin/PinTests/bin/Debug/PinTests.dll is the path to the .dll containing the tests to be executed and
nunit-report.xml is the file, generated in the same Debug folder that will be later used to obtain the test results in a nice format.
The last step is a post build step that will generate the test results. Just provide the .xml name from the previous step:
Run your Test
Now, you should be able to run your test, either manually, either periodically by making the desired settings in Build Triggers. The example below is executing the job every day at 6 AM:
After the run finishes you should see the test result similar with the image below:
Next week I'll explain how you can run your tests on different browsers by using the same .sln, an app.config and Jenkins.
Happy testing and... make it green, becomes a dream :).
Happy testing and... make it green, becomes a dream :).
For every post I'll recommend something to read. The link for today is:
Continuous Delivery: Reliable Software Releases through Build, Test, and Deployment Automation (Addison Wesley Signature Series)
No comments:
Post a Comment