Skip to content
This repository was archived by the owner on Jul 12, 2022. It is now read-only.

Verify Assert Argument Order #114

Merged
merged 1 commit into from
Apr 21, 2015

Conversation

ChadNedzlek
Copy link
Contributor

Test assert methods assume that the "actual" value is a variable
and the "expected" value is a constant for the most part. Inverting
these arguments causes misleading test failure messages that hinder
the ability to quickly diagnose test failures.

Detecting obvious mistakes (where "actual" is constant, and
"expected" is variable) can be done and the arguments swapped.

Fix #105

@ChadNedzlek
Copy link
Contributor Author

Anyone have any thoughts about this one?

@jaredpar
Copy link
Member

This seems like it should be in the XUnit formatter vs. the code formatter. The code formatter is generally domain agnostic and focussed on coding style. This is focusing on the correctness of a single domain.

@ChadNedzlek
Copy link
Contributor Author

Where is the "XUnit formatter"? I see the XUnitConverter, but that appears to be specifically about moving tests from one framework to another... not something you'd run on existing XUnit code... Though I could be mistaken.

@jaredpar
Copy link
Member

That is what I meant. That should be idempotent as well.

This may also be better as an analyzer / code fix.

@ChadNedzlek
Copy link
Contributor Author

Ah. I didn't realize it was intended to be run on already XUnit projects. I should be able to move it fairly quickly.

Test assert methods assume that the "actual" value is a variable
and the "expected" value is a constant for the most part. Inverting
these arguments causes misleading test failure messages that hinder
the ability to quickly diagnose test failures.

Detecting obvious mistakes (where "actual" is constant, and
"expected" is variable) can be done and the arguments swapped.

Fix dotnet#105
@ChadNedzlek ChadNedzlek force-pushed the verify-order-submit branch from 352309d to 0c6d48d Compare April 21, 2015 23:26
@ChadNedzlek
Copy link
Contributor Author

There. I've moved it to the XUnit converter project.

jaredpar added a commit that referenced this pull request Apr 21, 2015
@jaredpar jaredpar merged commit 3a16851 into dotnet:master Apr 21, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AssertXxx(actual, expected) where the "actual" is a constant should be reversed
3 participants