Skip to content

Commit 7c598f4

Browse files
authored
Simplify Dependencies a tad (#18236)
* simplify tests dependencies * OverallHintExperienceTests
1 parent 8473ce6 commit 7c598f4

File tree

7 files changed

+36
-43
lines changed

7 files changed

+36
-43
lines changed

eng/Versions.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@
193193
<XUnitVersion>2.9.0</XUnitVersion>
194194
<XUnitRunnerVersion>2.8.2</XUnitRunnerVersion>
195195
<XunitXmlTestLoggerVersion>3.1.17</XunitXmlTestLoggerVersion>
196-
<FluentAssertionsVersion>5.10.3</FluentAssertionsVersion>
197196
<HumanizerCoreVersion>2.2.0</HumanizerCoreVersion>
198197
<!-- -->
199198
<!-- MIBC profile packages -->

tests/FSharp.Compiler.Service.Tests/FsiTests.fs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
open System
44
open System.IO
5-
open FluentAssertions
65
open FSharp.Compiler.Interactive.Shell
76
open FSharp.Test
87
open Xunit
@@ -575,7 +574,7 @@ module FsiTests =
575574
fsiSession.AddBoundValue("boundMdArray", arr)
576575
let boundValue = fsiSession.GetBoundValues() |> List.exactlyOne
577576
Assert.shouldBe typeof<int[]> boundValue.Value.ReflectionType
578-
boundValue.Value.ReflectionValue.Should().Be(arr, "") |> ignore
577+
Assert.shouldBe arr boundValue.Value.ReflectionValue
579578

580579
[<Fact>]
581580
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 =
584583
fsiSession.AddBoundValue("boundMdArray", arr)
585584
let boundValue = fsiSession.GetBoundValues() |> List.exactlyOne
586585
Assert.shouldBe typeof<string[]> boundValue.Value.ReflectionType
587-
boundValue.Value.ReflectionValue.Should().Be(arr, "") |> ignore
586+
Assert.shouldBe arr boundValue.Value.ReflectionValue
588587

589588
[<Fact>]
590589
let ``Creation of a bound value succeeds if the value is an array of a custom value type``() =
@@ -593,7 +592,7 @@ module FsiTests =
593592
fsiSession.AddBoundValue("boundMdArray", arr)
594593
let boundValue = fsiSession.GetBoundValues() |> List.exactlyOne
595594
Assert.shouldBe typeof<CustomStruct[]> boundValue.Value.ReflectionType
596-
boundValue.Value.ReflectionValue.Should().Be(arr, "") |> ignore
595+
Assert.shouldBe arr boundValue.Value.ReflectionValue
597596

598597
[<Fact>]
599598
let ``Creation of a bound value succeeds if the value is an array of a custom reference type``() =
@@ -602,7 +601,7 @@ module FsiTests =
602601
fsiSession.AddBoundValue("boundMdArray", arr)
603602
let boundValue = fsiSession.GetBoundValues() |> List.exactlyOne
604603
Assert.shouldBe typeof<CustomType2[]> boundValue.Value.ReflectionType
605-
boundValue.Value.ReflectionValue.Should().Be(arr, "") |> ignore
604+
Assert.shouldBe arr boundValue.Value.ReflectionValue
606605

607606
[<Fact>]
608607
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 =
611610
fsiSession.AddBoundValue("boundMdArray", mdArr)
612611
let boundValue = fsiSession.GetBoundValues() |> List.exactlyOne
613612
Assert.shouldBe typeof<int[,]> boundValue.Value.ReflectionType
614-
boundValue.Value.ReflectionValue.Should().Be(mdArr, "") |> ignore
613+
Assert.shouldBe mdArr boundValue.Value.ReflectionValue
615614

616615
[<Fact>]
617616
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 =
620619
fsiSession.AddBoundValue("boundMdArray", mdArr)
621620
let boundValue = fsiSession.GetBoundValues() |> List.exactlyOne
622621
Assert.shouldBe typeof<string[,]> boundValue.Value.ReflectionType
623-
boundValue.Value.ReflectionValue.Should().Be(mdArr, "") |> ignore
622+
Assert.shouldBe mdArr boundValue.Value.ReflectionValue
624623

625624
[<Fact>]
626625
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 =
629628
fsiSession.AddBoundValue("boundMdArray", mdArr)
630629
let boundValue = fsiSession.GetBoundValues() |> List.exactlyOne
631630
Assert.shouldBe typeof<CustomStruct[,]> boundValue.Value.ReflectionType
632-
boundValue.Value.ReflectionValue.Should().Be(mdArr, "") |> ignore
631+
Assert.shouldBe mdArr boundValue.Value.ReflectionValue
633632

634633
[<Fact>]
635634
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 =
638637
fsiSession.AddBoundValue("boundMdArray", mdArr)
639638
let boundValue = fsiSession.GetBoundValues() |> List.exactlyOne
640639
Assert.shouldBe typeof<CustomType2[,]> boundValue.Value.ReflectionType
641-
boundValue.Value.ReflectionValue.Should().Be(mdArr, "") |> ignore
640+
Assert.shouldBe mdArr boundValue.Value.ReflectionValue
642641

643642
[<TheoryForNETCOREAPP>]
644643
[<InlineData(true)>]

tests/FSharp.Compiler.Service.Tests/ManglingNameOfProvidedTypes.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ type ManglingNamesOfProvidedTypesWithSingleParameter() =
3232
member this.DemangleDefaultValue() =
3333
let name, parameters = PrettyNaming.DemangleProvidedTypeName "MyNamespace.Test,"
3434
Assert.shouldBe "MyNamespace.Test" name
35-
Assert.shouldBeEquivalentTo [||] parameters
35+
Assert.shouldBeEmpty parameters
3636

3737
[<Fact>]
3838
member this.DemangleNewDefaultValue() =
3939
let name, parameters = PrettyNaming.DemangleProvidedTypeName "MyNamespace.Test"
4040
Assert.shouldBe "MyNamespace.Test" name
41-
Assert.shouldBeEquivalentTo [||] parameters
41+
Assert.shouldBeEmpty parameters
4242

4343

4444
type ManglingNamesOfProvidedTypesWithMultipleParameter() =

tests/FSharp.Compiler.Service.Tests/SuggestionBuffer.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ module SuggestionBuffer =
4141
let results = Array.ofSeq buffer
4242

4343
Assert.shouldBeTrue buffer.Disabled
44-
Assert.shouldBeEquivalentTo [||] results
44+
Assert.shouldBeEmpty results
4545

4646
[<Fact>]
4747
let BufferShouldOnlyTakeTop5Elements() =

tests/FSharp.Test.Utilities/Assert.fs

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,48 @@
11
namespace FSharp.Test
22

33
module Assert =
4-
open FluentAssertions
54
open System.Collections
65
open Xunit
76
open System.IO
87

8+
// Equivalent, with message
99
let inline shouldBeEqualWith (expected : ^T) (message: string) (actual: ^U) =
10-
actual.Should().BeEquivalentTo(expected, message) |> ignore
10+
try
11+
Assert.Equivalent(expected, actual)
12+
with e ->
13+
Assert.True(false, message);
1114

1215
let inline shouldBeEquivalentTo (expected : ^T) (actual : ^U) =
13-
actual.Should().BeEquivalentTo(expected, "") |> ignore
14-
15-
let inline shouldStartWith (expected : string) (actual : string) =
16-
actual.Should().StartWith(expected) |> ignore
17-
18-
let inline shouldContain (needle : string) (haystack : string) =
19-
haystack.Should().Contain(needle) |> ignore
16+
Assert.Equivalent(expected, actual)
2017

21-
// One fine day, all of the 3 things below should be purged and replaced with pure Assert.Equal.
22-
// Xunit checks types by default. These are just artifacts of the testing chaos in the repo back in a day.
2318
let inline shouldBe (expected : ^T) (actual : ^U) =
24-
actual.Should().Be(expected, "") |> ignore
19+
Assert.Equal(expected :> obj, actual :> obj)
20+
21+
let inline shouldStartWith (expected : string) (actual : string) =
22+
Assert.StartsWith(expected, actual)
23+
24+
let inline shouldContain (needle : string) (haystack : string) =
25+
Assert.Contains(needle, haystack)
2526

2627
let inline areEqual (expected: ^T) (actual: ^T) =
2728
Assert.Equal<^T>(expected, actual)
2829

2930
let inline shouldEqual (x: 'a) (y: 'a) =
3031
Assert.Equal<'a>(x, y)
31-
//
3232

3333
let inline shouldBeEmpty (actual : ^T when ^T :> IEnumerable) =
34-
actual.Should().BeEmpty("") |> ignore
34+
Assert.Empty(actual)
3535

3636
let inline shouldNotBeEmpty (actual : ^T when ^T :> IEnumerable) =
37-
actual.Should().NotBeEmpty("") |> ignore
37+
Assert.NotEmpty(actual)
3838

3939
let shouldBeFalse (actual: bool) =
40-
actual.Should().BeFalse("") |> ignore
40+
Assert.False(actual)
4141

4242
let shouldBeTrue (actual: bool) =
43-
actual.Should().BeTrue("") |> ignore
43+
Assert.True(actual)
4444

45-
let shouldBeSameMultilineStringSets expectedText actualText =
46-
45+
let shouldBeSameMultilineStringSets expectedText actualText =
4746
let getLines text =
4847
use reader = new StringReader(text)
4948
Seq.initInfinite (fun _ -> reader.ReadLine())

tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373

7474
<ItemGroup>
7575
<PackageReference Include="xunit" Version="$(XUnitVersion)" />
76-
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVersion)" />
7776
</ItemGroup>
7877

7978
<!-- Runtime dependencies. Beware. -->
@@ -83,14 +82,12 @@
8382
</ItemGroup>
8483

8584
<ItemGroup>
86-
87-
<InternalsVisibleTo Include="VisualFSharp.UnitTests" />
88-
<InternalsVisibleTo Include="FSharp.Compiler.ComponentTests" />
89-
<InternalsVisibleTo Include="FSharp.Compiler.Service.Tests" />
90-
<InternalsVisibleTo Include="FSharp.Tests.FSharpSuite" />
91-
<InternalsVisibleTo Include="LanguageServiceProfiling" />
92-
<InternalsVisibleTo Include="FSharp.Compiler.Benchmarks" />
93-
85+
<InternalsVisibleTo Include="VisualFSharp.UnitTests" />
86+
<InternalsVisibleTo Include="FSharp.Compiler.ComponentTests" />
87+
<InternalsVisibleTo Include="FSharp.Compiler.Service.Tests" />
88+
<InternalsVisibleTo Include="FSharp.Tests.FSharpSuite" />
89+
<InternalsVisibleTo Include="LanguageServiceProfiling" />
90+
<InternalsVisibleTo Include="FSharp.Compiler.Benchmarks" />
9491
</ItemGroup>
9592

9693
<ItemGroup>

tests/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@
1919

2020
## Framework for testing
2121

22-
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)**.
22+
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)**.
2323

2424
**Justification:**
2525

2626
* **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).
27-
* **FluentAssertions** makes it easier to write scoped assertions, provides better error messages.
2827

2928
**Alternatives:** NUnit, MSBuild, Expecto
3029

0 commit comments

Comments
 (0)