Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Expecto theory tests #1160

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testTheory is a feature of Expecto 10, which only supports .NET 6+, so I updated thise

<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"
}


]
Loading