create Console and Library Tests Overview page.

master
Craig Oates 5 years ago
parent
commit
3ba7bd8776
  1. 42
      Console-and-Library-Tests-Overview.md
  2. 2
      Home.md
  3. 2
      _sidebar.md

42
Console-and-Library-Tests-Overview.md

@ -0,0 +1,42 @@
Instead of going through both of the main testing files (I.E. "ConsoleTests.fs" and "LibraryTests.fs"), I will provide an overview of how they work. If you want to make your way through the source code you can do so by using the following links;
- [ConsoleTests.fs](https://gitlab.com/craig.oates/Death-Socket/blob/master/TestCentre/ConsoleTests.fs)
- [LibraryTests.fs](https://gitlab.com/craig.oates/Death-Socket/blob/master/TestCentre/LibraryTests.fs)
The general structure for each file is the same. Each one has a module called `PropertyTests` with "helper" functions at the top of them. It is worth pointing out both of these modules live in name-spaces. This is what allows both "testing" files to use the same module name. If you are wondering why I did it this way, it is because it makes it easier to read the Test Explorer (in Visual Studio). For now, the only unit tests you will see are in "ConsoleTests.fs", residing in the `UnitTests` module.
IMAGE OF TEST EXPLORER.
As an aside, I have kept the "helper" functions next to the actual tests for a reason: to avoid "over-engineering". It seemed a little excessive to "modularise" everything with such a small amount of tests. Although, I admit this approach will need to change if the repository grows in the future. If/when that time comes, TestCentre will need refactoring. Keep this in mind if you decide to add your own changes/features.
TEST FILE BREAKDOWN.
One way to denote a property test from a unit test is by looking at their attributes. If a test has `[<Property>]` next to it, it is a property test. If a test has `[<Fact>]` next to it, it is a unit test. For example,
```f#
// This is a unit test -- uses xUnit.
[<Fact>]
let ``Colour map is not empty`` () =
Assert.NotEmpty colourList
// This is a property test -- uses FsCheck.
[<Property>]
let ``Can create an image with a full overlay`` () =
resetSavingTestArea ()
let spec =
{ width = randomInt ()
height = randomInt ()
colour = randomColour () :?> Brush
filePath = saveLocation
overlay = Some (buildFullOverlay ()) }
makeImage spec |> Async.RunSynchronously
fileSaved (spec.width.ToString()) (spec.height.ToString()) = true
```
As stated in other parts of this wiki, make sure you have a folder called "SavingTestArea" within TestCentre. If you do not have this folder on your machine, a lot of the tests will fail. This is because TestCentre uses it as a place to save and check the images it creates. To help you check, here is what your TestCentre project should look like:
IMAGE OF FILE STRUCTURE IN TESTCENTRE.
The easiest way to add this folder to TestCentre is by right-clicking on "TestCentre" in Visual Studio's Solution Explorer. From there, head to _Add -> New Folder_. Having said that, you can add the "SavingTestArea" folder to TestCentre with File Explorer if you want. This is because Visual Studio does not need to know it exists. You just need it on your machine.
SCREENSHOT OF ADDING A NEW FOLDER.

2
Home.md

@ -63,7 +63,7 @@ Before continuing, I recommend you are familiar with the following;
- [Test Centre Home](Test-Centre-Home)
- [TestCentre Breakdown](TestCentre-Breakdown)
- [Property and Unit Tests Overview](Property-and-Unit-Tests-Overview)
- [Console and Library Tests Overview](Console-and-Library-Test-Overview)
- [Console and Library Tests Overview](Console-and-Library-Tests-Overview)
### As a Command-Line Interface (C.L.I.)

2
_sidebar.md

@ -20,7 +20,7 @@
- [Test Centre Home](Test-Centre-Home)
- [TestCentre Breakdown](TestCentre-Breakdown)
- [Property and Unit Tests Overview](Property-and-Unit-Tests-Overview)
- [Console and Library Tests Overview](Console-and-Library-Test-Overview)
- [Console and Library Tests Overview](Console-and-Library-Tests-Overview)
### As a Command-Line Interface (C.L.I.)

Loading…
Cancel
Save