How to Setup Jenkins and Integrate NUnit Selenium C# Framework?

Back to Blog
Jenkins Setup

How to Setup Jenkins and Integrate NUnit Selenium C# Framework?

Jenkins Setup

  1. Go to the Java download page and download Java Jdk Version 11.
  2. Add Java Paths to Environment Variables.

Jenkins Setup

3. Go to the Jenkins download page and download the latest LTS Jenkins. war file.

LTS jenkins

  1. 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

Command prompt

java -jar

  1. 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.
  2. Open the browser and navigate tohttp://localhost:8080/ to continue.
  3. Enter the admin password and click continue.

unlock jenkins

  1. Click on install suggested plugins and wait for the plugins to install.

Install plugins

  1. Once the plugins are installed either continue with the admin account or create a new account.

create a new account

  1. Click on Save and Finish

Instance Configuration

  1. Click on Start Using Jenkins

Jenkins

welcome Jenkins

  1. To login into Jenkins navigate to http://localhost:8080/or http://localhost:port/after starting the Jenkins server using the following command.

java -jar jenkins.war –httpPort=8080.

java -jar jenkins.war –httpPort=port.

If you are using an admin account then user name will be admin and the password can be retrieved from C:\Users\Ankur\.jenkins\secrets\initialAdminPassword.

Jenkins Tool

NUnit Selenium C# Framework Integration

  1. Refer to NUnit Selenium C# Framework for Jenkins integration
  2. Create a new Freestyle project for the framework

framework

 

  1. Select This project is parameterized option to add run-time parameters, I am passing browser options as parameters.

Source Code Management

  1. 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.

  1. Use Execute Windows batch Command to add the project build and execution commands.

Dotnet build

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

Windows batch Command

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%\”)

  1. Save the project and Select the Build with Parameters option to build the project and run the automation scripts with the selected browser option.

  1. After we click on the build button, we can navigate to the console output of the running job to view the results.

Console Output

Read Also:- Setting Up Jenkins on Amazon EC2 Ubuntu Instance

Share this post

Back to Blog