Project 1 - Unit Testing + Report

In the beginning of the project I did not have any difficulties in creating the test project environment. My test environment was implemented with the MSTest suite using the .NET core. This was chosen due to the fact that several of the members of my group use a macOS environment and I wanted to ensure compatibility across platforms when our tests were merged into our final submission. However, I quickly discovered a problem with this setup. Many of the program files from the source code are partial files that are linked to forms in order to represent the program GUI. When I attempted to create calls to instances of these classes I encountered an assembly error. I discovered that I could not properly create an instance of the class due to missing references to System.Windows.Forms in my test project. I spent a large amount of time researching how to add these references only to discover that they are not available in a .NET core setup. The only suggestions I could find to fix the issue were to use a unit test environment based on the full .NET framework. As this would likely cause merge conflicts due to the mixed development environment of my group I choose to change my target test methods to options that did not relate to classes utilizing windows forms.

After switching two of my test methods to avoid dealing with the forms dependency my next two major obstacles were the private nature of the methods I was testing and a lack of easily quantifiable return results. almost all the methods I was testing were private. However, with the permission of the professor I modified these methods to be public so that I could access them directly. I was also forced to make several member variables public for one method that had a void return value. The method’s implementation was difficult to assert with tests due it’s functionality being used only after many other function calls. I made several variables public in order to directly assert that the objective of the method had been completed as intended.

Another one of my methods provided a challenge due to a nested call to a virtual method. If the call executed to the virtual method it would throw an application exception due to a lack of implementation of the virtual method within the class. The method relied on subclasses to override the virtual method with a concrete implementation. I created two helper classes that would inherit the base class with overridden versions of the virtual method that return values useful for testing. I then created instances of my helper class in order to test all possible path’s of the target test method.

Overall, at a higher cyclomatic complexity level, the project became much more difficult to test in isolation due to the higher coupling between classes. The public API of the program also provided little access to many private methods making it difficult to perform unit tests of smaller blocks of the program.

Previous
Previous

Project 2 - Design

Next
Next

Project 1 - Planning