If you’re using Visual Studio 2017’s SPA templates for Angular, no doubt you’ve wanted to add third-party libraries such as Font Awesome. You could reference these dependencies in the index.html, but it would be better for performance if they were included in the webpack bundle. If you’ve never worked with webpack before, this could initially be a little confusing. But, don’t worry as it’s actually pretty simple.
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.
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).
So after a few hours of trying to figure out how to publish my MVC project in Visual Studio 2012 to my web server running Microsoft Server 2012, I finally got it working. I know there’s a lot of other blogs out there, but in order for me to get it working, I ended up having to take bits and pieces from multiple blogs and MSDN articles. So, I decided to compile what I’ve learned and share here on my blog.
Subscribe to receive new posts in your inbox.