Skip to content

Commit

Permalink
Add support for Expecto theory tests (ionide#1160)
Browse files Browse the repository at this point in the history
Co-authored-by: Richard Webb <[email protected]>
  • Loading branch information
2 people authored and nojaf committed Nov 3, 2023
1 parent d261b67 commit 59c9d73
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
9 changes: 9 additions & 0 deletions src/FsAutoComplete.Core/TestAdapter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ let getExpectoTests (ast: ParsedInput) : TestAdapterEntry<range> list =
|| str.EndsWith "testPropertyWithConfigs"
|| str.EndsWith "ptestPropertyWithConfigs"
|| str.EndsWith "ftestPropertyWithConfigs"
|| str.EndsWith "testTheory"
|| str.EndsWith "ftestTheory"
|| str.EndsWith "ptestTheory"
|| str.EndsWith "testTheoryAsync"
|| str.EndsWith "ftestTheoryAsync"
|| str.EndsWith "ptestTheoryAsync"
|| str.EndsWith "testTheoryTask"
|| str.EndsWith "ftestTheoryTask"
|| str.EndsWith "ptestTheoryTask"

let isExpectoListName (str: string) =
str.EndsWith "testList" || str.EndsWith "ftestList" || str.EndsWith "ptestList"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<GenerateProgramFile>false</GenerateProgramFile>
</PropertyGroup>

Expand All @@ -12,9 +12,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Expecto" Version="9.*" />
<PackageReference Include="YoloDev.Expecto.TestSdk" Version="0.13.3" />
<PackageReference Include="Expecto" Version="10.*" />
<PackageReference Include="YoloDev.Expecto.TestSdk" Version="0.14.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.*" />
<PackageReference Update="FSharp.Core" Version="4.*" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ open Expecto

[<EntryPoint>]
let main argv =
Tests.runTestsInAssembly defaultConfig argv
Tests.runTestsInAssemblyWithCLIArgs [] argv
13 changes: 13 additions & 0 deletions test/FsAutoComplete.Tests.Lsp/TestCases/ExpectoTests/Sample.fs
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,17 @@ let tests =
testAsync "simple async" {
Expect.equal 4 (2+2) "2+2"
}

testTheory "odd numbers" [1; 3; 5] <| fun x ->
Expect.isTrue (x % 2 = 1) "should be odd"

testTheoryAsync "async even numbers" [2; 4; 6] <| fun x -> async {
Expect.isTrue (x % 2 = 0) "should be even"
}

testTheoryTask "task odd numbers" [1; 3; 5;] <| fun x -> task {
Expect.isTrue (x % 2 = 1) "should be odd"
}


]

0 comments on commit 59c9d73

Please sign in to comment.