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:
- File names of JavaScript test file must be written as private class variable.
- Setup must load all production file.
- RunTest Method will be used to execute the Tests.
Read post 6 for the concluding guideline here.
2 comments