TUnit icon indicating copy to clipboard operation
TUnit copied to clipboard

Migration from XUnit is painful.

Open kant2002 opened this issue 5 months ago • 10 comments

Design which requires assert to be awaitable, make migration from XUnit or MSUnit or NUnit painful.

  1. All tests now have to be async Task which is.. you know... lot of typing.

  2. That looks super strange to compare things in awaitable fashion.

Assert.Equal(new char[] { 'D' }, input.ВисокошвидкосніПрінтери);

vs

await Assert.That(new char[] { 'D' }).IsEqualTo(input.ВисокошвидкосніПрінтери);
  1. Same problem but with untyped new.
Assert.Equal(new("PRODUCT-NO", 'A'), input.Перший);
Assert.Equal(new("PRODUCT-NO", 'B'), input.Другий);

become

await Assert.That(new ПосиланняНаПоле("PRODUCT-NO", 'A')).IsEqualTo(input.Перший);
await Assert.That(new ПосиланняНаПоле("PRODUCT-NO", 'B')).IsEqualTo(input.Другий);

notice that I have to write type name.

  1. Other small details, is that you cannot use collection initializers in your asserts, thus require rewriting tests again.

Probably only XUnit related.

var input = Assert.IsType<Input>(операція);

become

await Assert.That(операція).IsTypeOf(typeof(Input));
var input = (Input)операція;
  1. Cannot compare T and T? for simple types.
Assert.Equal((ushort)10, input.Більше);

become

await Assert.That((ushort?)10).IsEqualTo(input.Більше);
  1. Ooh. I just notice. You insist on having specific order of declaration
await Assert.That('A').IsEqualTo(input.ІсходнийФайл);

is invalid, since I have to rewrite like that.

await Assert.That(input.ІсходнийФайл).IsEqualTo('A');

which is understandable, but again. I have to retype a lot of code.

  1. I don't know what's going on, but when comparing arrays I cannot use IsEqualsTo and have to use IsEquivalentTo which is not what I expect from other frameworks.
  2. When I try to compare array of tuples, it does not work. Nor IsEqualsTo nor IsEquivalentTo works for me.
await Assert.That(input.ОписПереміщення).IsEquivalentTo(new (ПосиланняНаПоле ІсходнеПоле, ПосиланняНаПоле[] ЦільовіПоля)[] {
    (new ПосиланняНаПоле("PRODUCT-NO", 'A'), [new ПосиланняНаПоле("PRODUCT-NO", 'W')]),
    (new ПосиланняНаПоле("QUANTITY", 'A'), [new ПосиланняНаПоле("QUANTITY", 'W')]),
});

Summary

Overall I think migration process even for small set of 13 tests which I have , is very painful to my taste.

kant2002 avatar Sep 21 '24 11:09 kant2002