Unit Test Generation
The current version of the unit tests DLL works for most of FMStocks_DB.Account.Add().
Here are some things that are outstainding:
- The DLL needs to generate a project with the following naming scheme: <Project under test>.Tests.csproj
- The project under test needs to have the following authored into the AssemblyInfo.cs file:
[assembly: InternalsVisibleTo("FMStocks_DB.Tests")]“FMStocks_DB” in the above example is the name of the project under test.
-
The tests should be grouped by the function or property accessor under test. Here’s a screen cap demonstrating the project structure:

In the above, the “Tests” classes are named after the function under test, and the parent folder is the class or module under test. -
A UtilityFunctions class needs to be authored with at least the following:
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace FMStocks_DB.Tests{public static class UtilityFunctions{public static void ThrowException(){throw new Exception();}public static TReturn ThrowException<TReturn>(){throw new Exception();}}}The void function may be unnecessary, but the generic ThrowException is definitely needed.
-
There are a number of TODOs in the code. These are reminders for expansion on the functionality of the tests generator. For example, the generator needs to author tests for each external variable reference and members of those variables. That will help verify ALL of the state after a function call.
-
The current code for the generator relies on this script:
<gmBasic><Storage Action="Create" Identifier="DemoFMSLib_csh-UnitTests-std-csh" /><select Target="C:\gmProj\FMStocks_csh\usr" /><Select Local="C:\gmProj\FMStocks_csh\idf\FromCode" /><Select System="C:\gmProj\FMStocks_csh\idf\FromIdl" /><LoadRuntime Dllname="UnitTests.dll" /><Output Status="New" Filename="C:\gmProj\FMStocks_csh\report\UnitTests-log.txt" /><GatherData Identifier="DemoFMSLib_csh-FMStocks_DB-std-csh" /><Storage Action="Close" /></gmBasic> -
The current code generator also looks for a specific VBI file and only generates code for a specific function.
-
JustMock is unable to mock private functions with ByRef parameters. I was going to create a function that would allow this to work properly. It’ll require the use of reflection to execute the same steps for private functions without ByRef parameters. It might violate the license of JustMock if that’s done, so it’s probably just as well that this isn’t implemented.
-
Integer values are the only ones that are iterating right now.
-
See my unit testing page for other ideas on things that need done.