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

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

Integrating MS Test to execute the JavaScript test:

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace WebPortal.Tests.JSTest
{
 [TestClass]
 public class FirstJavaScriptTests : JavaScriptTestBase
 {
  //Path of file name is critical here.
  private const string ProductionCodeFileName
  = @"..\..\..\..\WebPortal.Tests\SampleProduction.js";
  private const string TestCodeFileName
  = @"..\..\..\..\WebPortal.Tests\SampleTest.js";

  /// <summary>
  /// Setup is where you set Production files
  /// </summary>
  [TestInitialize]
  public void Setup()
  {
     AppendProdJavaScriptFile(ProductionCodeFileName);
  }

  [TestMethod]
  public void ReturnSumOfTwoNumber()
  {
     RunTest(TestCodeFileName, "returnSumOfTwoNumber");
  }
 }
}

Code is explained below:

  1. File names of JavaScript test file must be written as private class variable.
  2. Setup must load all production file.
  3. RunTest Method will be used to execute the Tests.

Read post 6 for the concluding guideline here.

Advertisements

2 thoughts on “JSTest.NET from Nuget integration with MS Test Series Part 5

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s