5 TestCentre Breakdown
Craig Oates edited this page 4 years ago

testcentre selected

This project is a traditional .Net (4.7) library, written in F#. Its main purpose is to house the solution's unit and property tests.

Within the project, you will see nine files and a folder; And, inside that folder is another five files. This brings the total number of files to fourteen. Of the fourteen, you should spend most of your time in two of them. They are "PropertyTests.fs" and "UnitTests.fs".

testcentre file structure

The "AssemblyInfo.fs", "TestCentre.fsproj" and "packages.config" file are all standard files. You will find them in most F# based (traditional) .Net libraries. Because of this, I will not go into too much detail about them here.

PropertyTests.fs

This file houses TestCentre's property tests. As stated in other parts of this wiki, I wrote them with FsCheck. If you are unfamiliar with FsCheck, you can find out more about it with the following link:

TextFiles Folder

This folder houses the plain-text (.txt) files need to complete the tests within this project. Within "TextFiles" are the following files:

  • console-waterworks-announcement.txt
  • desktop-clock-info.txt
  • invalid-text.txt
  • test-post.txt
  • word-generator.txt

There is nothing special about these files. They are regular .txt files and mimic the .txt files used in the WetPancake (NuGet) project -- apart from "invalid-text.txt".

UnitTests.fs

This file houses TestCentre's unit tests. I wrote them with xUnit; so, you can use Visual Studio's Test Explorer to help visualise the passing and failing tests. You should find UnitTest.fs contains several modules within it -- grouping together various categories of unit tests.

You can find out more about xUnit and Visual Studio's Test Explorer by using the following links:

The Test Explorer will display the property tests and unit tests side-by-side.

Helpers.fs

This file contains functions which reduces the amount of "noise" in the main unit and property tests. If you find yourself writing a test and it starts to bloat (E.G. extra conditional checks), consider abstracting it into a function and placing it in here. You can, also, use it as a place to store repeatable bits of code.

InputGeneration.fs

This is more purposeful version of "Helpers.fs". The functions in here provide you with ways to generate random(ish) input to test against, at run-time. The code in here is aware of the files in "TextFiles" and uses them to generate the input.

TestingConstants.fs

In here, you will find (constant) variables which are available throughout TestCentre. They mostly store file paths. These constants help reduce the amount of copy-and-pasted code/repeated code throughout TestCentre.

Script.fsx

This file is a little different than the others. This is because it is a script file. It contains none of the actual code needed for TestCentre to function as intended. Instead, it is a place to test ideas out before committing them to the main code-base. You should consider everything in this file as "throw-away".

If you are unsure how to use a script (.fsx) file with F# Interactive (FSI), please use the following links: