Skip to content

Commit

Permalink
Migrate VisualFSharp tests to Xunit (dotnet#17751)
Browse files Browse the repository at this point in the history
* 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) <codecutter@hotmail.com>
  • Loading branch information
2 people authored and esbenbjerre committed Sep 30, 2024
1 parent d380caa commit 197029b
Show file tree
Hide file tree
Showing 37 changed files with 2,046 additions and 2,759 deletions.
8 changes: 0 additions & 8 deletions TESTGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,6 @@ Tags are in the left column, paths to to corresponding test folders are in the r

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.

### VisualFSharp.UnitTests

These are currently NUnit tests (we hope to migrate them to xUnit). You can execute these tests individually via the Visual Studio NUnit3 runner
extension or the command line via `nunit3-console.exe`.

Note that for compatibility reasons, the IDE unit tests should be run in a 32-bit process,
using the `--x86` flag to `nunit3-console.exe`

### Logs and output

All test execution logs and result files will be dropped into the `tests\TestResults` folder, and have file names matching
Expand Down
7 changes: 0 additions & 7 deletions vsintegration/tests/UnitTests/AssemblyResolver.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Microsoft.VisualStudio.FSharp

open NUnit.Framework
open System
open System.IO
open System.Reflection
Expand Down Expand Up @@ -46,9 +45,3 @@ module AssemblyResolver =
match found() with
| None -> Unchecked.defaultof<Assembly>
| Some name -> Assembly.Load(name) )

[<SetUpFixture>]
type public AssemblyResolverTestFixture () =

[<OneTimeSetUp>]
member public _.Init () = AssemblyResolver.addResolver ()
9 changes: 3 additions & 6 deletions vsintegration/tests/UnitTests/DocCommentIdParserTests.fs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
[<NUnit.Framework.TestFixture>]

module Tests.ServiceAnalysis.DocCommentIdParser

open NUnit.Framework
open Xunit
open Microsoft.VisualStudio.FSharp.Editor




[<Test>]
[<Fact>]
let ``Test DocCommentId parser``() =
let testData = dict [
"T:N.X.Nested", DocCommentId.Type ["N"; "X"; "Nested"];
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ namespace Tests.LanguageService.ErrorRecovery

open System
open System.IO
open NUnit.Framework
open Xunit
open Salsa.Salsa
open Salsa.VsOpsUtils
open UnitTests.TestLib.Salsa
open UnitTests.TestLib.Utils
open UnitTests.TestLib.LanguageService
open UnitTests.TestLib.ProjectSystem

[<TestFixture>]
[<Category "LanguageService">]
type UsingMSBuild() =
inherit LanguageServiceBaseTests()

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

Assert.IsTrue(errorList
Assert.True(errorList
|> GetErrorMessages
|> Seq.exists (fun errorMessage ->
errorMessage.Contains(expectedStr)))

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

// Not a recovery case, but make sure we get a squiggle at the unfinished Main()
[<Test>]
[<Category("error_recovery")>]
[<Fact>]
member public this.``ErrorRecovery.Bug4538_4``() =
let fileContent = """
type MyType() =
Expand All @@ -54,8 +50,7 @@ type UsingMSBuild() =
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."
this.VerifyErrorListContainedExpectedString(fileContent,expectedStr)

[<Test>]
[<Category("error_recovery")>]
[<Fact>]
member public this.``ErrorRecovery.Bug4881_1``() =
let code =
["let s = \"\""
Expand All @@ -70,8 +65,7 @@ type UsingMSBuild() =
let completions = AutoCompleteAtCursor file
AssertCompListContains(completions,"Split")

[<Test>]
[<Category("error_recovery")>]
[<Fact>]
member public this.``ErrorRecovery.Bug4881_2``() =
let code =
["let s = \"\""
Expand All @@ -87,8 +81,7 @@ type UsingMSBuild() =
let completions = AutoCompleteAtCursor file
AssertCompListContains(completions,"Split")

[<Test>]
[<Category("error_recovery")>]
[<Fact>]
member public this.``ErrorRecovery.Bug4881_3``() =
let code =
["let s = \"\""
Expand All @@ -105,8 +98,7 @@ type UsingMSBuild() =
AssertCompListContains(completions,"Split")


[<Test>]
[<Category("error_recovery")>]
[<Fact>]
member public this.``ErrorRecovery.Bug4881_4``() =
let code =
["let s = \"\""
Expand All @@ -122,8 +114,7 @@ type UsingMSBuild() =


// This case was fixed while investigating 4538.
[<Test>]
[<Category("error_recovery")>]
[<Fact>]
member public this.``ErrorRecovery.NotFixing4538_1``() =
let code =
["type MyType() = "
Expand All @@ -139,8 +130,7 @@ type UsingMSBuild() =
AssertCompListContains(completions,"MyType")

// This case was fixed while investigating 4538.
[<Test>]
[<Category("error_recovery")>]
[<Fact>]
member public this.``ErrorRecovery.NotFixing4538_2``() =
let code =
["type MyType() = "
Expand All @@ -156,8 +146,7 @@ type UsingMSBuild() =
AssertCompListContains(completions,"MyType")

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

[<Test>]
[<Category("error_recovery")>]
[<Fact>]
member public this.``ErrorRecovery.Bug4538_1``() =
let code =
["type MyType() = "
Expand All @@ -187,8 +175,7 @@ type UsingMSBuild() =
let completions = CtrlSpaceCompleteAtCursor file
AssertCompListContains(completions,"MyType")

[<Test>]
[<Category("error_recovery")>]
[<Fact>]
member public this.``ErrorRecovery.Bug4538_2``() =
let code =
["type MyType() = "
Expand All @@ -207,8 +194,7 @@ type UsingMSBuild() =



[<Test>]
[<Category("error_recovery")>]
[<Fact>]
member public this.``ErrorRecovery.Bug4538_5``() =
let code =
["type MyType() = "
Expand All @@ -224,8 +210,7 @@ type UsingMSBuild() =
AssertCompListContains(completions,"MyType")


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


// Context project system
[<TestFixture>]
type UsingProjectSystem() =
inherit UsingMSBuild(VsOpts = LanguageServiceExtension.ProjectSystemTestFlavour)
Loading

0 comments on commit 197029b

Please sign in to comment.