diff --git a/eng/Versions.props b/eng/Versions.props index 00bbbc51afb..59f0f6e7cb9 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -193,7 +193,6 @@ 2.9.0 2.8.2 3.1.17 - 5.10.3 2.2.0 diff --git a/tests/FSharp.Compiler.Service.Tests/FsiTests.fs b/tests/FSharp.Compiler.Service.Tests/FsiTests.fs index bb3e8407d6f..208f7a465a6 100644 --- a/tests/FSharp.Compiler.Service.Tests/FsiTests.fs +++ b/tests/FSharp.Compiler.Service.Tests/FsiTests.fs @@ -2,7 +2,6 @@ open System open System.IO -open FluentAssertions open FSharp.Compiler.Interactive.Shell open FSharp.Test open Xunit @@ -575,7 +574,7 @@ module FsiTests = fsiSession.AddBoundValue("boundMdArray", arr) let boundValue = fsiSession.GetBoundValues() |> List.exactlyOne Assert.shouldBe typeof boundValue.Value.ReflectionType - boundValue.Value.ReflectionValue.Should().Be(arr, "") |> ignore + Assert.shouldBe arr boundValue.Value.ReflectionValue [] let ``Creation of a bound value succeeds if the value is an array of a built-in reference type``() = @@ -584,7 +583,7 @@ module FsiTests = fsiSession.AddBoundValue("boundMdArray", arr) let boundValue = fsiSession.GetBoundValues() |> List.exactlyOne Assert.shouldBe typeof boundValue.Value.ReflectionType - boundValue.Value.ReflectionValue.Should().Be(arr, "") |> ignore + Assert.shouldBe arr boundValue.Value.ReflectionValue [] let ``Creation of a bound value succeeds if the value is an array of a custom value type``() = @@ -593,7 +592,7 @@ module FsiTests = fsiSession.AddBoundValue("boundMdArray", arr) let boundValue = fsiSession.GetBoundValues() |> List.exactlyOne Assert.shouldBe typeof boundValue.Value.ReflectionType - boundValue.Value.ReflectionValue.Should().Be(arr, "") |> ignore + Assert.shouldBe arr boundValue.Value.ReflectionValue [] let ``Creation of a bound value succeeds if the value is an array of a custom reference type``() = @@ -602,7 +601,7 @@ module FsiTests = fsiSession.AddBoundValue("boundMdArray", arr) let boundValue = fsiSession.GetBoundValues() |> List.exactlyOne Assert.shouldBe typeof boundValue.Value.ReflectionType - boundValue.Value.ReflectionValue.Should().Be(arr, "") |> ignore + Assert.shouldBe arr boundValue.Value.ReflectionValue [] let ``Creation of a bound value succeeds if the value is a multidimensional array of a built-in value type``() = @@ -611,7 +610,7 @@ module FsiTests = fsiSession.AddBoundValue("boundMdArray", mdArr) let boundValue = fsiSession.GetBoundValues() |> List.exactlyOne Assert.shouldBe typeof boundValue.Value.ReflectionType - boundValue.Value.ReflectionValue.Should().Be(mdArr, "") |> ignore + Assert.shouldBe mdArr boundValue.Value.ReflectionValue [] let ``Creation of a bound value succeeds if the value is a multidimensional array of a built-in reference type``() = @@ -620,7 +619,7 @@ module FsiTests = fsiSession.AddBoundValue("boundMdArray", mdArr) let boundValue = fsiSession.GetBoundValues() |> List.exactlyOne Assert.shouldBe typeof boundValue.Value.ReflectionType - boundValue.Value.ReflectionValue.Should().Be(mdArr, "") |> ignore + Assert.shouldBe mdArr boundValue.Value.ReflectionValue [] let ``Creation of a bound value succeeds if the value is a multidimensional array of a custom value type``() = @@ -629,7 +628,7 @@ module FsiTests = fsiSession.AddBoundValue("boundMdArray", mdArr) let boundValue = fsiSession.GetBoundValues() |> List.exactlyOne Assert.shouldBe typeof boundValue.Value.ReflectionType - boundValue.Value.ReflectionValue.Should().Be(mdArr, "") |> ignore + Assert.shouldBe mdArr boundValue.Value.ReflectionValue [] let ``Creation of a bound value succeeds if the value is a multidimensional array of a custom reference type``() = @@ -638,7 +637,7 @@ module FsiTests = fsiSession.AddBoundValue("boundMdArray", mdArr) let boundValue = fsiSession.GetBoundValues() |> List.exactlyOne Assert.shouldBe typeof boundValue.Value.ReflectionType - boundValue.Value.ReflectionValue.Should().Be(mdArr, "") |> ignore + Assert.shouldBe mdArr boundValue.Value.ReflectionValue [] [] diff --git a/tests/FSharp.Compiler.Service.Tests/ManglingNameOfProvidedTypes.fs b/tests/FSharp.Compiler.Service.Tests/ManglingNameOfProvidedTypes.fs index 5f8fd967342..cd728482876 100644 --- a/tests/FSharp.Compiler.Service.Tests/ManglingNameOfProvidedTypes.fs +++ b/tests/FSharp.Compiler.Service.Tests/ManglingNameOfProvidedTypes.fs @@ -32,13 +32,13 @@ type ManglingNamesOfProvidedTypesWithSingleParameter() = member this.DemangleDefaultValue() = let name, parameters = PrettyNaming.DemangleProvidedTypeName "MyNamespace.Test," Assert.shouldBe "MyNamespace.Test" name - Assert.shouldBeEquivalentTo [||] parameters + Assert.shouldBeEmpty parameters [] member this.DemangleNewDefaultValue() = let name, parameters = PrettyNaming.DemangleProvidedTypeName "MyNamespace.Test" Assert.shouldBe "MyNamespace.Test" name - Assert.shouldBeEquivalentTo [||] parameters + Assert.shouldBeEmpty parameters type ManglingNamesOfProvidedTypesWithMultipleParameter() = diff --git a/tests/FSharp.Compiler.Service.Tests/SuggestionBuffer.fs b/tests/FSharp.Compiler.Service.Tests/SuggestionBuffer.fs index 04494592586..bc5c82f0b61 100644 --- a/tests/FSharp.Compiler.Service.Tests/SuggestionBuffer.fs +++ b/tests/FSharp.Compiler.Service.Tests/SuggestionBuffer.fs @@ -41,7 +41,7 @@ module SuggestionBuffer = let results = Array.ofSeq buffer Assert.shouldBeTrue buffer.Disabled - Assert.shouldBeEquivalentTo [||] results + Assert.shouldBeEmpty results [] let BufferShouldOnlyTakeTop5Elements() = diff --git a/tests/FSharp.Test.Utilities/Assert.fs b/tests/FSharp.Test.Utilities/Assert.fs index 41287757a0f..dc1df050fed 100644 --- a/tests/FSharp.Test.Utilities/Assert.fs +++ b/tests/FSharp.Test.Utilities/Assert.fs @@ -1,49 +1,48 @@ namespace FSharp.Test module Assert = - open FluentAssertions open System.Collections open Xunit open System.IO + // Equivalent, with message let inline shouldBeEqualWith (expected : ^T) (message: string) (actual: ^U) = - actual.Should().BeEquivalentTo(expected, message) |> ignore + try + Assert.Equivalent(expected, actual) + with e -> + Assert.True(false, message); let inline shouldBeEquivalentTo (expected : ^T) (actual : ^U) = - actual.Should().BeEquivalentTo(expected, "") |> ignore - - let inline shouldStartWith (expected : string) (actual : string) = - actual.Should().StartWith(expected) |> ignore - - let inline shouldContain (needle : string) (haystack : string) = - haystack.Should().Contain(needle) |> ignore + Assert.Equivalent(expected, actual) - // One fine day, all of the 3 things below should be purged and replaced with pure Assert.Equal. - // Xunit checks types by default. These are just artifacts of the testing chaos in the repo back in a day. let inline shouldBe (expected : ^T) (actual : ^U) = - actual.Should().Be(expected, "") |> ignore + Assert.Equal(expected :> obj, actual :> obj) + + let inline shouldStartWith (expected : string) (actual : string) = + Assert.StartsWith(expected, actual) + + let inline shouldContain (needle : string) (haystack : string) = + Assert.Contains(needle, haystack) let inline areEqual (expected: ^T) (actual: ^T) = Assert.Equal<^T>(expected, actual) let inline shouldEqual (x: 'a) (y: 'a) = Assert.Equal<'a>(x, y) - // let inline shouldBeEmpty (actual : ^T when ^T :> IEnumerable) = - actual.Should().BeEmpty("") |> ignore + Assert.Empty(actual) let inline shouldNotBeEmpty (actual : ^T when ^T :> IEnumerable) = - actual.Should().NotBeEmpty("") |> ignore + Assert.NotEmpty(actual) let shouldBeFalse (actual: bool) = - actual.Should().BeFalse("") |> ignore + Assert.False(actual) let shouldBeTrue (actual: bool) = - actual.Should().BeTrue("") |> ignore + Assert.True(actual) - let shouldBeSameMultilineStringSets expectedText actualText = - + let shouldBeSameMultilineStringSets expectedText actualText = let getLines text = use reader = new StringReader(text) Seq.initInfinite (fun _ -> reader.ReadLine()) diff --git a/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj b/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj index 4a255384e07..192783edd57 100644 --- a/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj +++ b/tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj @@ -73,7 +73,6 @@ - @@ -83,14 +82,12 @@ - - - - - - - - + + + + + + diff --git a/tests/README.md b/tests/README.md index 40c9a35b177..81202f86f4e 100644 --- a/tests/README.md +++ b/tests/README.md @@ -19,12 +19,11 @@ ## Framework for testing -The following test frameworks and libraries will be used for new test projects **[xUnit Test Framework](https://xunit.net/), [FluentAssertions](https://fluentassertions.com/) (+ [FsUnit](https://fsprojects.github.io/FsUnit/) and [FsCheck](https://github.com/fscheck/FsCheck) when needed)**. +The following test frameworks and libraries will be used for new test projects **[xUnit Test Framework](https://xunit.net/) and [FsCheck](https://github.com/fscheck/FsCheck) when needed)**. **Justification:** * **xUnit** is an extensible, TDD adherent, testing framework, which was successfully adopted by many .NET engineering teams, including Roslyn, AspNetCore, EFcore, etc, has a "cleaner" approach for writing test suites (i.e. class constructor for setup, implementing IDisposable for teardown, as oppose to custom attributes). More info [here](https://xunit.net/docs/comparisons). -* **FluentAssertions** makes it easier to write scoped assertions, provides better error messages. **Alternatives:** NUnit, MSBuild, Expecto