Skip to content

Commit c967543

Browse files
committed
Show error notification in client for expectable test discovery issues (i.e projects not restored or built)
1 parent 740cfb1 commit c967543

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/FsAutoComplete/LspServers/AdaptiveServerState.fs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2599,6 +2599,28 @@ type AdaptiveState
25992599
let! testProjects = TestProjectHelpers.tryGetTestProjects workspaceLoader state.WorkspacePaths
26002600
let testProjectBinaries = testProjects |> List.map _.TargetPath
26012601

2602+
if testProjects |> List.isEmpty then
2603+
let message = "No test projects found. Make sure you've restored your projects"
2604+
2605+
do!
2606+
lspClient.WindowShowMessage(
2607+
{ Type = MessageType.Error
2608+
Message = message }
2609+
)
2610+
2611+
return! (Error message)
2612+
elif testProjectBinaries |> List.filter File.Exists |> List.isEmpty then
2613+
let message =
2614+
"No binaries found for test projects. Make sure you've built your projects"
2615+
2616+
do!
2617+
lspClient.WindowShowMessage(
2618+
{ Type = MessageType.Error
2619+
Message = message }
2620+
)
2621+
2622+
return! (Error message)
2623+
26022624
let tryTestCasesToDTOs testCases =
26032625
let projectLookup = testProjects |> Seq.map (fun p -> p.TargetPath, p) |> Map.ofSeq
26042626

test/FsAutoComplete.Tests.Lsp/TestExplorerTests.fs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,19 @@ let tests createServer =
6464
testSequenced
6565
<| testList
6666
"TestExplorerTests"
67-
[ testCaseAsync "it should report tests of all basic outcomes"
67+
[ testCaseAsync "it should error if the workspace hasn't been built"
68+
<| async {
69+
let workspaceRoot =
70+
Path.Combine(__SOURCE_DIRECTORY__, "SampleTestProjects", "VSTest.XUnit.RunResults")
71+
72+
let! server, _ = initializeServer workspaceRoot
73+
use server = server
74+
75+
let! res = server.TestDiscoverTests()
76+
77+
Expect.isTrue res.IsError ""
78+
}
79+
testCaseAsync "it should report tests of all basic outcomes"
6880
<| async {
6981
let workspaceRoot =
7082
Path.Combine(__SOURCE_DIRECTORY__, "SampleTestProjects", "VSTest.XUnit.RunResults")

0 commit comments

Comments
 (0)