skip to content

What changed in FluentAssertions 8's licence, what does License.Accepted really do, and why do some ASP.NET Core teams move to Shouldly?

level: middleimportance: should knowfreq 40%

answer

  1. Xceed Community License from 8.0
  2. commercial use needs a paid licence
  3. soft warning, no licence key
  4. License.Accepted hides the warning only
  5. ShouldBe reads the calling source

basics

~20 s

From version 8 FluentAssertions is under Xceed's licence: free for open-source and non-commercial use, paid for commercial use. License.Accepted = true only suppresses the runtime warning. Teams that will not pay pin 7.x or move to BSD-licensed Shouldly.

solid answer

~40 s

FluentAssertions 8.0 moved from an open-source licence to Xceed's Community License Agreement: free for open-source projects and non-commercial use, while commercial use requires a paid licence from Xceed. Version 7 stays open source and keeps receiving fixes. There is no licence key; instead, the first assertion of a run prints a soft warning to the console and trace output unless `License.Accepted` is `true`. Since 8.1 you can set it from an `[assembly: AssertionEngineInitializer(...)]` method, but it **only hides the warning**; it does not grant a licence. A commercial team therefore pays, pins 7.x, or moves to **Shouldly**, which is BSD-licensed. Shouldly's style is extension methods: `patient.LastName.ShouldBe("Okafor")`, `ShouldBeEquivalentTo`, `Should.Throw<T>(...)`, `ShouldSatisfyAllConditions`. Its failure message quotes the asserting source expression, which needs full PDBs and the source on the build agent.

code

csharp · 12 lines
csharp
// FluentAssertions 8
patient.LastName.Should().Be("Okafor");
result.Should().BeEquivalentTo(expected, o => o.Excluding(p => p.Id));
act.Should().Throw<InvalidOperationException>();

// Shouldly 4
patient.LastName.ShouldBe("Okafor");
result.ShouldBeEquivalentTo(expected);              // no exclusion options
Should.Throw<InvalidOperationException>(act);
patient.ShouldSatisfyAllConditions(
    () => patient.Status.ShouldBe(PatientStatus.Active),
    () => patient.Email.ShouldContain("@"));

go deeper

for a junior

Remember the facts: FluentAssertions 8+ is free only for open-source and non-commercial use, version 7 stays open source, and Shouldly is a BSD-licensed alternative.

for a middle

Explain the mechanics: no key, a soft warning, License.Accepted only silences it, and Shouldly's messages come from reading the source at runtime.

for a senior

Lead the decision with numbers: licence cost against pinning 7.x or migrating, and the gaps such as equivalency options and PDB requirements.

for a principal

Set a dependency policy for licence changes in test libraries, so the next relicensing is caught at review time rather than by an update bot.

## What happened with version 8 FluentAssertions (`FluentAssertions` on NuGet) gives .NET tests the `subject.Should().Be(expected)` style. Its 8.0 release notes open with a **licence change**: - versions 8 and beyond are free for **open-source projects and non-commercial use**; - **commercial use requires a paid licence** from Xceed Software, now the project's partner; - **version 7 remains fully open source** and keeps receiving bug fixes and important corrections. The LICENSE file in the 8.x repository is the *Xceed Software Inc. Community License Agreement, Fluent Assertions (for Non-Commercial Use)*. It defines non-commercial use (open-source software, personal or experimental projects, organisations that earn no revenue, work that is not sold) and states that any other use needs a commercial licence. The test project of a company's clinic-scheduling API falls outside those parameters. ## The soft warning and License.Accepted FluentAssertions 8 has **no licence key** and does not stop working. When the assertion engine initialises, it prints a warning about the Xceed licence through `Console.WriteLine` and `Trace.WriteLine`, unless the static `FluentAssertions.License.Accepted` property is `true`. Version 8.1 added that toggle, and the documented way to set it runs before the first assertion: ```csharp [assembly: FluentAssertions.Extensibility.AssertionEngineInitializer( typeof(FaInit), nameof(FaInit.AcknowledgeSoftWarning))] public static class FaInit { public static void AcknowledgeSoftWarning() => License.Accepted = true; } ``` The property's own documentation says it is used to accept the licence and **suppress the soft warning**. Setting it is a statement by the team, not a purchase; it changes no terms. ## The three options a team has | Option | What it costs | What to watch | |---|---|---| | Buy commercial licences | money, per Xceed's terms | nothing in the code changes | | Pin FluentAssertions 7.x | no new features from 8 onwards | upgrade bots that propose 8.x; keep the range below 8 | | Move to Shouldly | rewriting assertions | different equivalency options and failure-message mechanism | Pinning in Central Package Management looks like `<PackageVersion Include="FluentAssertions" Version="[7.0.0,8.0.0)" />`, so a restore can never pick 8. ## What Shouldly offers Shouldly (`Shouldly` on NuGet, version 4.0.3, BSD-licensed) puts assertions on the subject as extension methods: - `patient.LastName.ShouldBe("Okafor")` instead of `patient.LastName.Should().Be("Okafor")`; - `actual.ShouldBeEquivalentTo(expected)` for a structural comparison of object graphs; - `Should.Throw<InvalidOperationException>(() => scheduler.Book(...))` and `ShouldThrowAsync` for exceptions; - `patient.ShouldSatisfyAllConditions(() => ..., () => ...)` to report several failures together, the counterpart of FluentAssertions' `AssertionScope`; - `ShouldBeNull`, `ShouldContain`, `ShouldBeInRange` and many more. Its distinctive feature is the **failure message**: `patient.LastName should be "Okafor" but was "Okafro"`. Shouldly reads the source code of the line that made the assertion, so it can name the expression. The README warns that the build agent therefore needs full PDB files where the tests run; `ShouldlyConfiguration.DisableSourceInErrors()` turns the source lookup off. ## Migration notes 1. Equivalency differs. FluentAssertions' `BeEquivalentTo(expected, o => o.Excluding(p => p.Id))` has options to exclude or re-map members; Shouldly's `ShouldBeEquivalentTo(expected)` has no options argument, so tests that relied on exclusions need the excluded members set equal first, or separate assertions. 2. Messages differ. Tests that assert on a library's failure text, which is rare but exists in custom assertion helpers, need rewriting. 3. Do it mechanically. Most `x.Should().Be(y)` calls map one to one; convert per project and keep both libraries only during the move. ## What to say in an interview State the licence facts as the repository states them, distinguish suppressing the warning from being licensed, and present the decision as a cost comparison rather than a moral one. A good answer also shows awareness of the wider pattern: test-only dependencies are easy to overlook in licence reviews because they never ship to production, yet a licence covers use, not deployment. Keeping test packages in the same dependency review as production packages, with versions pinned through Central Package Management, catches the next change of terms before an automated update merges it.

  • Does setting License.Accepted = true make commercial use of FluentAssertions 8 compliant?
    No. The property only suppresses the soft warning that the assertion engine prints; the library has no key and checks nothing. Compliance comes from the licence terms: free for open-source and non-commercial use, a paid Xceed licence otherwise. Setting the flag in a commercial project without a licence just hides the reminder.
  • Why do Shouldly failure messages sometimes lose the expression text on a build server?
    Shouldly builds the message by finding and reading the source line that called the assertion. Without full PDBs or without the source files at the path the PDB records, it cannot find the line and falls back to a less specific message. Ship full PDBs with the test build or accept the shorter messages; `ShouldlyConfiguration.DisableSourceInErrors()` turns the lookup off deliberately.

  • FluentAssertions 8 stops working without a licence key in commercial projects.
  • Setting License.Accepted = true is what licenses FluentAssertions 8 for commercial use.
  • FluentAssertions 7 also moved to the Xceed licence and stopped receiving fixes.
  • Shouldly's ShouldBeEquivalentTo accepts the same Excluding options as BeEquivalentTo.
  • Shouldly needs no PDBs; its messages come from compile-time caller expressions.

Assumes FluentAssertions 8.11 (licence change in 8.0, License.Accepted toggle added in 8.1) and Shouldly 4.0.3, used from ASP.NET Core 10 test projects.