-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create NUnit 3.0 glue library page for AutoFixture #20
Conversation
@elindanielsson, @agnerh |
@@ -0,0 +1,275 @@ | |||
AutoFixture offers a glue library for NUnit 3.0. In AutoFixture's lingo, a glue library is a library that extend one library (in this case NUnit 3.0) with AutoFixture. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a short description on why we want to use the glue library here? I can see some advantages mentioned in the text below but I think it would be nice to have it in the intro text here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
By using this library, developers can speed up the process of creating unit tests and, while doing so, creating unit tests that are easier to read.
docs/NUnit-glue-library.md
Outdated
[Test] | ||
[AutoData] | ||
public void Echo_returns_same_message(Service sut, string message) | ||
{ | ||
// ACT | ||
var result = sut.Echo(message); | ||
|
||
// ASSERT | ||
Assert.That(result, Is.EqualTo(message)); | ||
} | ||
``` | ||
|
||
The unit test above can be converted to the equivalent without taking advantage of the `AutoData` attribute. | ||
|
||
```csharp | ||
[Test] | ||
public void Echo_returns_same_message() | ||
{ | ||
// ARRANGE | ||
var fixture = new Fixture(); | ||
var sut = fixture.Create<Service>(); | ||
var message = fixture.Create<string>(); | ||
|
||
// ACT | ||
var result = sut.Echo(message); | ||
|
||
// ASSERT | ||
Assert.That(result, Is.EqualTo(message)); | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will be easier to parse if the "old" way is comes before the "new" way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add few lines here about what the benefits of using AutoData
instead of arranging manually?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
Assert.That(result, Is.EqualTo(first + second)); | ||
} | ||
``` | ||
As shown above, unlike the `AutoData` attribute, the `InlineAutoData` attribute can be applied more than once on the same unit test. Each instance of the attribute will generate a new execution of the unit test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we expand a bit more on how the example above will run? How many executions and with what parameters in which execution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
docs/NUnit-glue-library.md
Outdated
|
||
Another issue deriving from delegating AutoFixture of instantiating classes like system under tests is the loss of control on which constructor is picked. By default, AutoFixture picks the constructor with least parameters, but sometimes this is not the optimal choice. | ||
|
||
The `Greedy` and `Modest` attributes give the developer the power to instruct AutoFixture which constructor to select when constructing an object to be passed to NUnit. The `Greedy` attribute will instruct AutoFixture to use the constructor with the most parameters while the `Modest` attribute will instruct AutoFixture in the opposite way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the opposite way
The opposite way how?
If it's just picking the constructor with the least parameters then why would someone use it since it's the default behavior?
Could we also add a short sentence about the scenario when the constructor you want to pick is neither the one with the most or the least parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, the need for [Modest]
is unclear to me too.
Co-authored-by: Henrik Agner <32951545+agnerh@users.noreply.github.com>
Creates the page containing information about the AutoFixture.NUnit3 package.
Fixes #16