Your ultimate guide

Showing posts with label NUnit. Show all posts
Showing posts with label NUnit. Show all posts

Creating NUnit Projects



What is NUnit?
    NUnit is an Open source unit testing framework for Microsoft .NET, it works the same as Junit or TestNG framework in Java.

In Java, we have a framework called JUnit, TestNG
In Python, we have Framework PyTest
In JavaScript, we have MOKA, JASMIN
For C# it is NUnit.

NUnit Features:
  • Tests can be run in parallel
  • Every Test Case can be added to one or more categories or to allow selective running
  • Skip the tests
  • Order can be set to tests
  • Parameterization­­­­
  • Data-driven Testing


Creating NUnit Projects:
  • Right-click on the Solution folder Select Add  Click on New Project


  • Select Project type as Test.
  • Select the project template as NUnit Test Project  Click on Next.
  • And give the Project name and Location  Click on Next.
  • Select the Target Framework  Click on Create.


 

When we open NUnit Project, we will see one default Class with the name on UnitTest.cs.

It contains one Example program ⬇:

namespace NUnitSelenium

{
    public class Tests
    {
        [SetUp]
        public void Setup()
        {
        }
        
        [Test]
        public void Test1()
        {
            Assert.Pass();
        }
    }
}

[SetUp]:

    If you have pre-requests for the test like launching the browser, setting the implicit time out, maximizing, cleaning up the data, and hitting the URL ….. all pre-requests we mention here.

[Test]:

    Test Attribute holds the core logic. Whatever the functionalities we perform we write in the Test attribute.

[TearDown]:

    The last thing which will happen after the Test Attribute run is, Close the browser, delete the cookies and delete the data …. And so on.

 

 

 

How to run any NUnit test:

  • First, we need to build the entire project. For that Click on Build menu > then select Build solution.
  • After the build is done then we access the test explorer. (Click on Test  menu > then Click on Test Explorer) 

  • Now In the Test Explorer, we can run the Test attributes individually:
  • For that, Right-click on the Test (on the Explorer tab) then click on Run.

  • To see the output, On the output tab select Show output from: as Tests.



- Next Page: C# Selenium

Selenium with C# along with NUnit Framework

Selenium With C# along with NUnit Framework:

0. Difference Between C# and Java

"The content on this page is currently being developed and is not yet complete. Please check again later for updates." 
 
1. Visual Studio Setup
2. C# Basics, and about NuGet
3. C# Basics 2
4. Creating NUnit Project








The rest of the Content will be Uploaded Soon!