From f1860a522cf4d45a9ec208158aea724495b43e42 Mon Sep 17 00:00:00 2001 From: Richard Webb Date: Tue, 5 Sep 2023 09:51:14 +0100 Subject: [PATCH] Add support for Expecto theory tests --- src/FsAutoComplete.Core/TestAdapter.fs | 9 +++++++++ .../TestCases/ExpectoTests/ExpectoTests.fsproj | 9 ++++----- .../TestCases/ExpectoTests/Main.fs | 2 +- .../TestCases/ExpectoTests/Sample.fs | 13 +++++++++++++ 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/FsAutoComplete.Core/TestAdapter.fs b/src/FsAutoComplete.Core/TestAdapter.fs index 694861fa1..840855223 100644 --- a/src/FsAutoComplete.Core/TestAdapter.fs +++ b/src/FsAutoComplete.Core/TestAdapter.fs @@ -73,6 +73,15 @@ let getExpectoTests (ast: ParsedInput) : TestAdapterEntry 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" diff --git a/test/FsAutoComplete.Tests.Lsp/TestCases/ExpectoTests/ExpectoTests.fsproj b/test/FsAutoComplete.Tests.Lsp/TestCases/ExpectoTests/ExpectoTests.fsproj index f065837b8..6b3eb875c 100644 --- a/test/FsAutoComplete.Tests.Lsp/TestCases/ExpectoTests/ExpectoTests.fsproj +++ b/test/FsAutoComplete.Tests.Lsp/TestCases/ExpectoTests/ExpectoTests.fsproj @@ -1,8 +1,8 @@ - + Exe - netcoreapp3.1 + net6.0 false @@ -12,9 +12,8 @@ - - + + - diff --git a/test/FsAutoComplete.Tests.Lsp/TestCases/ExpectoTests/Main.fs b/test/FsAutoComplete.Tests.Lsp/TestCases/ExpectoTests/Main.fs index 362418e1f..5bd74a243 100644 --- a/test/FsAutoComplete.Tests.Lsp/TestCases/ExpectoTests/Main.fs +++ b/test/FsAutoComplete.Tests.Lsp/TestCases/ExpectoTests/Main.fs @@ -3,4 +3,4 @@ open Expecto [] let main argv = - Tests.runTestsInAssembly defaultConfig argv + Tests.runTestsInAssemblyWithCLIArgs [] argv diff --git a/test/FsAutoComplete.Tests.Lsp/TestCases/ExpectoTests/Sample.fs b/test/FsAutoComplete.Tests.Lsp/TestCases/ExpectoTests/Sample.fs index d318fa20a..1f608c9ab 100644 --- a/test/FsAutoComplete.Tests.Lsp/TestCases/ExpectoTests/Sample.fs +++ b/test/FsAutoComplete.Tests.Lsp/TestCases/ExpectoTests/Sample.fs @@ -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" + } + + ]