JSTest.NET from Nuget integration with MS Test Series Part 3

This is part 3 of 6 posts, you can find the previous post here.

Sample JavaScript test in .js file:

The Add function mentioned in the previous post can have a test code as mentioned below:

function returnSumOfTwoNumber() {
    //Arrange
    var expectedOutput = 3;
    var actualOutput = null;

    //Act
    actualOutput = Add(1,2);

    //Assert
    assertEqual(expectOutput, actualOutput);
}

The keyword here is assertEqual to match the expected output to actual output.

Other points will be explained in following post, read  Part 4 here.

JSTest.NET from Nuget integration with MS Test Series Part 2

This is part 2 of 6 posts, you can find the previous post here.

Structural Overview of different component & its role:

Below mentioned are different component of Tests:

  1. Actual JavaScript file which contains the production code.
  2. JavaScript Test file which contains the test methods.
  3. JavaScriptTestBase.cs is a helper class for writing better MS Test.
  4. Actual MS Test file to run the test mentioned in JavaScript file.

Example of sample function of JavaScript is

function returnSumOfTwoNumber() {
         assertEqual(3, Add(1,2));
}

Other points will be explained in following post, read Part 3 here.