Sunday 5 June 2016

Run the Unit testing of Angular Applications in Visual studio Test Explorer using Chutzpah Test Adapter

In this post we are going to see how to run the test cases in the Visual Studio Test Explorer using Chutzpah Test Adapter.

Before proceeding with this please refer the following link to install the Jasmine and Chutzpah Test Runner in your applications (Visual Studio)   we have to do the following steps before install the chutzpah test adapter for running the applications in chutzpah test runner.

How to install and Configure the Chutzpah test runner in Visual studio


First to do this we have to install the extension of Chutzpah Test Adapter for visual studio. Already i had installed the chutzpah test runner which is used to run the Js for Testing.

Visual Studio :  Tools - > Extensions and Updates    -> Type Chutzpah in search


























we can see in the above image that Test Runner is already installed, after installing the Chutzpah restart the application, Now give a Rebuild or build in the Visual studio then only applications are get updated. Now Go to View -> TestExplorer and click it. You can see Test explorer updated with some tests, now click Run all.

App Code:


 Test Code:



Test Explorer



In the  above images it shows more cases are failed, but we had written the 6 test cases, then why so many cases are listed it is because of _references.js,  this file have the entry of each js, so when test explorer scans this file it haves our test file also so again the Test file is scanned for testing , for that location it will give error for all test cases so remove the Test File js entry from the _reference.js, Now again Give Build in Solution, we can get the updated test cases now.





above image shows the correct test cases , now click Run all , This will run the test cases, Now we have one issue , a Test case is failed, so we are going to see the details in the Details section. Below image have the detail explanation of test case error. That the expected value is wrong is the issue






From this post you can see how to run the test cases in test explorer of Visual studio using the Chutzpah Test Adapter. By this way you can enable the UI for testing the test cases of Angular Applications. In the Later Post we will see how to test the Applications using Karma JS.


No comments:

Post a Comment