Skip to content

Latest commit

 

History

History
176 lines (121 loc) · 5.75 KB

MacOS_Other_Gui_Expecto_GitHubActions.md

File metadata and controls

176 lines (121 loc) · 5.75 KB

Getting Started Wizard

Home > MacOS > Other > Prefer GUI > Expecto > GitHub Actions

Add NuGet packages

Add the following packages to the test project:

<PackageReference Include="YoloDev.Expecto.TestSdk" Version="0.14.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Expecto" Version="10.2.1" />
<PackageReference Include="Verify.Expecto" Version="23.5.2" />
<PackageReference Update="FSharp.Core" Version="8.0.200" />

snippet source | anchor

Implicit Usings

All examples use Implicit Usings. Ensure the following is set to have examples compile correctly <ImplicitUsings>enable</ImplicitUsings>

If ImplicitUsings are not enabled, substitute usages of Verify() with Verifier.Verify().

Source Control

Includes/Excludes

  • All *.received.* files should be excluded from source control.

eg. add the following to .gitignore

*.received.*

If using UseSplitModeForUniqueDirectory also include:

*.received/

All *.verified.* files should be committed to source control.

Text file settings

Text variants of verified and received have the following characteristics:

This manifests in several ways:

Source control settings

All text extensions of *.verified.* should have:

  • eol set to lf
  • working-tree-encoding set to UTF-8

eg add the following to .gitattributes

*.verified.txt text eol=lf working-tree-encoding=UTF-8
*.verified.xml text eol=lf working-tree-encoding=UTF-8
*.verified.json text eol=lf working-tree-encoding=UTF-8

EditorConfig settings

If modifying text verified/received files in an editor, it is desirable for the editor to respect the above conventions. For EditorConfig enabled the following can be used:

# Verify settings
[*.{received,verified}.{txt,xml,json}]
charset = "utf-8-bom"
end_of_line = lf
indent_size = unset
indent_style = unset
insert_final_newline = false
tab_width = unset
trim_trailing_whitespace = false

Note that the above are suggested for subset of text extension. Add others as required based on the text file types being verified.

DiffPlex

The text comparison behavior of Verify is pluggable. The default behaviour, on failure, is to output both the received and the verified contents as part of the exception. This can be noisy when verifying large strings.

Verify.DiffPlex changes the text compare result to highlighting text differences inline.

This is optional, but recommended.

Add the NuGet

<PackageReference Include="Verify.DiffPlex" Version="*" />

Enable

[ModuleInitializer]
public static void Initialize() =>
    VerifyDiffPlex.Initialize();

Sample Test

open Expecto
open VerifyTests
open VerifyExpecto

[<Tests>]
let tests =
    testTask "findPerson" {
        let person = ClassBeingTested.FindPerson()
        do! Verifier.Verify("findPerson", person)
    }

snippet source | anchor

Diff Tool

Verify supports many Diff Tools for comparing received to verified. While IDEs are supported, due to their MDI nature, using a different Diff Tool is recommended.

Tools supported by MacOS:

Getting .received in output on GitHub Actions

Use a if: failure() condition to upload any *.received.* files if the build fails.

- name: Upload Test Results
  if: failure()
  uses: actions/upload-artifact@v2
  with:
    name: verify-test-results
    path: |
      **/*.received.*