I’ve been developing a LOT of Angular applications lately. Some of them are hybrid projects (Angular w/ MVC); some of my projects have been completely separated (Angular for client-side, with a separate project for an API). Regardless, I always want to ensure that my code has been thoroughly tested with unit tests and acceptance (E2E) tests. When developing hybrid projects, my preferred IDE is Visual Studio. When developing a pure, client-side project, my preferred IDE is Visual Studio Code as it has a lot less remnants/artifacts tied to a solution (.vs, .xproj, .csproj, etc.) eliminating the need for a ridiculously large .gitignore file. Additionally, I will use WebStorm depending on the need.
Jasmine is a great framework for providing both unit testing and end-to-end, acceptance testing. Coupled with Karma, Jasmine can monitor file changes to our client-side code and execute tests on every file change in order to ensure that all tests are always passing. In this blog post, I will demonstrate how to set up and use Karma and Jasmine in both development environments.
The other day I was writing some unit tests for testing my MVC application’s forms authentication classes. I needed to Mock the System.Web.HttpContext object. There are a couple of ways to do this depending on the version of Visual Studio you are using (i.e. Professional, Premium/Ultimate/Enterprise) and how deep you wish to provide some default data. One takes a little more leg work and requires some manual data setting, but gives you greater control. While the other requires less coding for simple basic use.
The other day I was writing some unit tests on an MVC project. I needed to mock (fake) an HttpRequest object using the System.Web assembly. However, there was a strange issue in creating the fakes assembly and adding it to my Visual Studio solution. Namely, it didn’t show up.Read more
Do your MVC model properties contain attributes? Have you ever wanted to unit test the properties to verify that the ModelState fails or succeeds based on given values? Below is a static method that can be used for your unit tests as you test your models.
In an earlier post, I provided step-by-step instructions in how to perform Behavior Driven Development using Visual Studio, SpecFlow, WatiN and DryRunner. However, I’ve had a lot of students and blog readers ask me about Selenium, a more-common browser automation tool. So, I’m writing this post to show how to accomplish BDD and automated test driven development (ATDD) using Selenium.Read more
In the previous post, we examined some of the principles behind BDD. If you read it, I’m sure you’re thinking, “Wow! That’s great! But, how do I accomplish this in Visual Studio?” There are a myriad of posts on the Internet that demonstrate different components. However, there’s not really a single post with all of the information compiled. For that reason, I’m going to provide a step-by-step tutorial on how to perform BDD with Visual Studio. Additionally, I will show you how to perform automated testing using your Gherkin scripts.
According to AgileAlliance.org:
BDD (Behavior Driven Development) is a synthesis and refinement of practices stemming from TDD (Test Driven Development) and ATDD (Acceptance Test Driven Development).
That’s great, but what does that really mean?
BDD has its roots in TDD, but supersedes TDD in the agile development process. BDD recognizes that User Stories are the framework for the development process and that these stories determine the necessary tasks required to satisfy given business requirements. Read more
As a Microsoft Certified Trainer over the past 2 years, I’ve had the opportunity of teaching hundreds of professionals how to properly engage in unit testing. Amazingly enough, even though unit testing has been around quite a while, it is still a concept that is very infantile in the corporate arena. Most developers who have adopted unit testing are those who work for start-ups or the few companies who’ve started to embrace agile methodologies executing test-driven development (TDD).
Subscribe to receive new posts in your inbox.