Skip to content

Commit 2907d59

Browse files
Migrate VisualFSharp tests to Xunit (#17751)
* Migrate last Nunit tests to Xunit * up * up * up * Update TestLib.LanguageService.fs * up * up * up * Remove unused tests * one more * up --------- Co-authored-by: Kevin Ransom (msft) <[email protected]>
1 parent 398d16d commit 2907d59

37 files changed

+2046
-2759
lines changed

TESTGUIDE.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,6 @@ Tags are in the left column, paths to to corresponding test folders are in the r
151151

152152
If you want to re-run a particular test area, the easiest way to do so is to set a temporary tag for that area in test.lst (e.g. "RERUN") and adjust `ttags` [run.fsharpqa.test.fsx script](tests/fsharpqa/run.fsharpqa.test.fsx) and run it.
153153

154-
### VisualFSharp.UnitTests
155-
156-
These are currently NUnit tests (we hope to migrate them to xUnit). You can execute these tests individually via the Visual Studio NUnit3 runner
157-
extension or the command line via `nunit3-console.exe`.
158-
159-
Note that for compatibility reasons, the IDE unit tests should be run in a 32-bit process,
160-
using the `--x86` flag to `nunit3-console.exe`
161-
162154
### Logs and output
163155

164156
All test execution logs and result files will be dropped into the `tests\TestResults` folder, and have file names matching

vsintegration/tests/UnitTests/AssemblyResolver.fs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace Microsoft.VisualStudio.FSharp
22

3-
open NUnit.Framework
43
open System
54
open System.IO
65
open System.Reflection
@@ -46,9 +45,3 @@ module AssemblyResolver =
4645
match found() with
4746
| None -> Unchecked.defaultof<Assembly>
4847
| Some name -> Assembly.Load(name) )
49-
50-
[<SetUpFixture>]
51-
type public AssemblyResolverTestFixture () =
52-
53-
[<OneTimeSetUp>]
54-
member public _.Init () = AssemblyResolver.addResolver ()

vsintegration/tests/UnitTests/DocCommentIdParserTests.fs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
2-
[<NUnit.Framework.TestFixture>]
2+
33
module Tests.ServiceAnalysis.DocCommentIdParser
44

5-
open NUnit.Framework
5+
open Xunit
66
open Microsoft.VisualStudio.FSharp.Editor
77

8-
9-
10-
11-
[<Test>]
8+
[<Fact>]
129
let ``Test DocCommentId parser``() =
1310
let testData = dict [
1411
"T:N.X.Nested", DocCommentId.Type ["N"; "X"; "Nested"];

vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.Completion.fs

Lines changed: 564 additions & 698 deletions
Large diffs are not rendered by default.

vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.ErrorList.fs

Lines changed: 77 additions & 123 deletions
Large diffs are not rendered by default.

vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.ErrorRecovery.fs

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ namespace Tests.LanguageService.ErrorRecovery
44

55
open System
66
open System.IO
7-
open NUnit.Framework
7+
open Xunit
88
open Salsa.Salsa
99
open Salsa.VsOpsUtils
1010
open UnitTests.TestLib.Salsa
1111
open UnitTests.TestLib.Utils
1212
open UnitTests.TestLib.LanguageService
1313
open UnitTests.TestLib.ProjectSystem
1414

15-
[<TestFixture>]
16-
[<Category "LanguageService">]
1715
type UsingMSBuild() =
1816
inherit LanguageServiceBaseTests()
1917

@@ -25,14 +23,13 @@ type UsingMSBuild() =
2523
[ for i = 0 to errorList.Length - 1 do
2624
yield errorList.[i].Message]
2725

28-
Assert.IsTrue(errorList
26+
Assert.True(errorList
2927
|> GetErrorMessages
3028
|> Seq.exists (fun errorMessage ->
3129
errorMessage.Contains(expectedStr)))
3230

3331
// Not a recovery case, but make sure we get a squiggle at the unfinished Main()
34-
[<Test>]
35-
[<Category("error_recovery")>]
32+
[<Fact>]
3633
member public this.``ErrorRecovery.Bug4538_3``() =
3734
let fileContent = """
3835
type MyType() =
@@ -43,8 +40,7 @@ type UsingMSBuild() =
4340
this.VerifyErrorListContainedExpectedString(fileContent,expectedStr)
4441

4542
// Not a recovery case, but make sure we get a squiggle at the unfinished Main()
46-
[<Test>]
47-
[<Category("error_recovery")>]
43+
[<Fact>]
4844
member public this.``ErrorRecovery.Bug4538_4``() =
4945
let fileContent = """
5046
type MyType() =
@@ -54,8 +50,7 @@ type UsingMSBuild() =
5450
let expectedStr = "The block following this 'use' is unfinished. Every code block is an expression and must have a result. 'use' cannot be the final code element in a block. Consider giving this block an explicit result."
5551
this.VerifyErrorListContainedExpectedString(fileContent,expectedStr)
5652

57-
[<Test>]
58-
[<Category("error_recovery")>]
53+
[<Fact>]
5954
member public this.``ErrorRecovery.Bug4881_1``() =
6055
let code =
6156
["let s = \"\""
@@ -70,8 +65,7 @@ type UsingMSBuild() =
7065
let completions = AutoCompleteAtCursor file
7166
AssertCompListContains(completions,"Split")
7267

73-
[<Test>]
74-
[<Category("error_recovery")>]
68+
[<Fact>]
7569
member public this.``ErrorRecovery.Bug4881_2``() =
7670
let code =
7771
["let s = \"\""
@@ -87,8 +81,7 @@ type UsingMSBuild() =
8781
let completions = AutoCompleteAtCursor file
8882
AssertCompListContains(completions,"Split")
8983

90-
[<Test>]
91-
[<Category("error_recovery")>]
84+
[<Fact>]
9285
member public this.``ErrorRecovery.Bug4881_3``() =
9386
let code =
9487
["let s = \"\""
@@ -105,8 +98,7 @@ type UsingMSBuild() =
10598
AssertCompListContains(completions,"Split")
10699

107100

108-
[<Test>]
109-
[<Category("error_recovery")>]
101+
[<Fact>]
110102
member public this.``ErrorRecovery.Bug4881_4``() =
111103
let code =
112104
["let s = \"\""
@@ -122,8 +114,7 @@ type UsingMSBuild() =
122114

123115

124116
// This case was fixed while investigating 4538.
125-
[<Test>]
126-
[<Category("error_recovery")>]
117+
[<Fact>]
127118
member public this.``ErrorRecovery.NotFixing4538_1``() =
128119
let code =
129120
["type MyType() = "
@@ -139,8 +130,7 @@ type UsingMSBuild() =
139130
AssertCompListContains(completions,"MyType")
140131

141132
// This case was fixed while investigating 4538.
142-
[<Test>]
143-
[<Category("error_recovery")>]
133+
[<Fact>]
144134
member public this.``ErrorRecovery.NotFixing4538_2``() =
145135
let code =
146136
["type MyType() = "
@@ -156,8 +146,7 @@ type UsingMSBuild() =
156146
AssertCompListContains(completions,"MyType")
157147

158148
// This case was fixed while investigating 4538.
159-
[<Test>]
160-
[<Category("error_recovery")>]
149+
[<Fact>]
161150
member public this.``ErrorRecovery.NotFixing4538_3``() =
162151
let code =
163152
["type MyType() = "
@@ -171,8 +160,7 @@ type UsingMSBuild() =
171160
let completions = CtrlSpaceCompleteAtCursor file
172161
AssertCompListContains(completions,"MyType")
173162

174-
[<Test>]
175-
[<Category("error_recovery")>]
163+
[<Fact>]
176164
member public this.``ErrorRecovery.Bug4538_1``() =
177165
let code =
178166
["type MyType() = "
@@ -187,8 +175,7 @@ type UsingMSBuild() =
187175
let completions = CtrlSpaceCompleteAtCursor file
188176
AssertCompListContains(completions,"MyType")
189177

190-
[<Test>]
191-
[<Category("error_recovery")>]
178+
[<Fact>]
192179
member public this.``ErrorRecovery.Bug4538_2``() =
193180
let code =
194181
["type MyType() = "
@@ -207,8 +194,7 @@ type UsingMSBuild() =
207194

208195

209196

210-
[<Test>]
211-
[<Category("error_recovery")>]
197+
[<Fact>]
212198
member public this.``ErrorRecovery.Bug4538_5``() =
213199
let code =
214200
["type MyType() = "
@@ -224,8 +210,7 @@ type UsingMSBuild() =
224210
AssertCompListContains(completions,"MyType")
225211

226212

227-
[<Test>]
228-
[<Category("error_recovery")>]
213+
[<Fact>]
229214
member public this.``ErrorRecovery.Bug4594_1``() =
230215
let code =
231216
["let Bar(xyz) ="
@@ -241,7 +226,7 @@ type UsingMSBuild() =
241226
/// In this bug, the Module. at the very end of the file was treated as if it were in the scope
242227
/// of Module rather than right after it. This check just makes sure we can see a data tip because
243228
/// Module is available.
244-
[<Test>]
229+
[<Fact>]
245230
member public this.``ErrorRecovery.5878_1``() =
246231
Helper.AssertMemberDataTipContainsInOrder
247232
(
@@ -268,6 +253,5 @@ type UsingMSBuild() =
268253

269254

270255
// Context project system
271-
[<TestFixture>]
272256
type UsingProjectSystem() =
273257
inherit UsingMSBuild(VsOpts = LanguageServiceExtension.ProjectSystemTestFlavour)

0 commit comments

Comments
 (0)