I will do integration tests (some on the server as I did with the existing .NET 4.6.x code I ported over (to be replaced) and some via Selenium (also like I did in the .NET 4.6.x website)), but I wanted to focus on that a little further down the road. Ideally, that would be written along with the unit tests following a Test Driven Design (TDD) methodology, but I am anxious to explore the Graphic User Interface (GUI) perspective 🙂
I did find one contender that (so far) has met my requirements – JSTest.Net created by Chris Baxter. Locally, it was as easy to install via Nuget and my simple test worked.
- Sample Test
- File/Function under test
- Running test
So, I added my tests and initially, everything worked as expected. I then tried a pipeline build and was surprised when I got an error. Upon more digging, the nuget restore of this project was not found.
This predictably caused the build to fail.
Some initial research did not reveal an easy solution, so I disabled the check in build integration and checked in and deployed the site manually. I did not want to spend a lot of time (again) dealing with the pipeline.
Guided by the documentation, I was able to create unit tests for:
- Run together
With this working, I contemplated how I could get my pipeline to work with this apparently rogue nuget package. So, I forked JSTest.Net, downloaded it and tried building it…lots of errors. I also noticed that it was no longer maintained. Given how useful this package is to me and my needs, I may attempt to get my fork compiling and working, but for now, I am going to reference the nuget .dll file (old school, I know) and store with my code. Not ideal, but it works 🙂
Adding the JSTest.dll file as a local reference and running all tests throw VS 2017 works.
Initially, the pipeline broke because of my references. I removed that test project, added a .Net Core test project (duh Eric 🙂 ), ported over my test code and voila it works 🙂
Website after build.
I would still like to figure out the injection thing so I can test my Global.js Load() method, so I will either do that or move on to the Login page.