Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

141
Vistas
FsUnit showing two identical expected values for F# types

The two tests below fail, of course. But why do the error messages show two identical expected values? Is there a way of only showing one?

myTest returns Expected: <B> or <B> But was: <A>

myTest2 returns Expected: <{ N = 2 }> or <{ N = 2 }> But was: <{ N = 1 }>

This works as expected (e.g. Expected: <B> But was: <A>) when using plain NUnit instead.

This gets pretty nasty when working with more complicated types, of course.

Tests.cs:

namespace Blah

open FsUnit
open NUnit.Framework

module Tests =

    type MyDU = A | B

    type MyRecord = { N: int }

    [<Test>]
    let myTest ()=
        A |> should equal B

    [<Test>]
    let myTest2 ()=
        { N = 1 } |> should equal { N = 2 }

Project file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Tests.fs" />
  </ItemGroup>
  
  <ItemGroup>
    <PackageReference Update="FSharp.Core" Version="5.0.2" />
    <PackageReference Include="FsUnit" Version="4.2.0" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
    <PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
  </ItemGroup>
  
</Project>
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

From looking at the source, it looks like this is the reason:

equal for 'structural equatable' items like records and unions use the NUnit constraint:

Is.EqualTo(x).Or.EqualTo(x).Using<'T>(Equality.Structural)

And this constraint will feed into the error message.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda