How to Setup Jenkins and Integrate NUnit Selenium C# Framework?
- Go to the Java download page and download Java Jdk Version 11.
- Add Java Paths to Environment Variables.
3. Go to the Jenkins download page and download the latest LTS Jenkins. war file.
4. Open a Command prompt and move to the location where the downloaded jenkins.war is present and enter the following command. If port 8080 is not available use port 9090.
java -jar jenkins.war –httpPort=8080
5. Save the admin password generated in the previous step to continue. From the previous step the admin password is 08a25f8a193b455a9b3f7e106e320b72 which can be retrieved from C:\Users\Ankur\.jenkins\secrets\initialAdminPassword.
6. Open the browser and navigate tohttp://localhost:8080/ to continue.
7. Enter the admin password and click continue.
8. Click on install suggested plugins and wait for the plugins to install.
9. Once the plugins are installed either continue with the admin account or create a new account.
10. Click on Save and Finish
11. Click on Start Using Jenkins
java -jar jenkins.war –httpPort=8080.
java -jar jenkins.war –httpPort=port.
If you are using an admin account then the user name will be admin and the password can be retrieved from C:\Users\Ankur\.jenkins\secrets\initialAdminPassword.
NUnit Selenium C# Framework Integration
- Refer to NUnit Selenium C# Framework for Jenkins integration
- Create a new Freestyle project for the framework
3. Select This project is parameterized option to add run-time parameters, I am passing browser options as parameters.
4. Give project path after selecting the Use custom workspace option. If the project is present on git, we can use the Source Code Management option and add the git project path.
5. Use Execute Windows batch Command to add the project build and execution commands.
To pass parameters at run time we use the .runsettings file. In our project, we are using browser parameters with the default value Chrome. To use the .runsettings file we can use the following test command
Dotnet test -s CalculatorFramework/test.runsettings
If we want to pass browser value at run time from Jenkins then we can use the following test command. Here browser value be replaced by the Jenkins choice parameter value.
Dotnet test — TestRunParameters.Parameter(name=\”Browser\”, value=\”%Browsers%\”)
6. Save the project and Select the Build with Parameters option to build the project and run the automation scripts with the selected browser option.
7. After we click on the build button, we can navigate to the console output of the running job to view the results.
Read Also:- Setting Up Jenkins on Amazon EC2 Ubuntu Instance
Originally published at https://www.devstringx.com on May 10, 2022