Loading...

nunit-discuss@googlegroups.com

[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: [nunit-discuss] Parameterized testfixture with default ctor Charlie Poole Tue Apr 03 10:08:09 2012

Hi Roger,

Thanks for posting this here. It seems to me we should have a feature
like this in 3.0, but I'd like to hear what others think.

There would be a few issues to work out.

1. What would the syntax look like? Some new attribute on the property
is one obvious approach.

2. If you combine the existing constructor injection with propoerty
injection, how should that work? For example, what if you coded...

   [TestFixture(5, "hello")]
   [TestFixture(6, "goodbye")]
   public class MyClass(int num, string word)
   {
      [Inject(1, 2, 3)]
      public int SomeProperty { get; set; }

      ...
   }

   How many instances would we create? Of course this may be a
pathological example, but we have to deal with it some way.

3. Alternatively, can we figure out some way to keep the property
values on the TestFixtureAttribute, without creating a non-default
constructor?

4. What about allowing values to be passed to the SetUp or
SetUpFixture method? And how would that interact with everything else.

Charlie


On Tue, Apr 3, 2012 at 4:02 AM, Roger Kratz <[EMAIL PROTECTED]> wrote:
> (similar question posted here:
> https://answers.launchpad.net/nunitv2/+question/189098)
>
> Hi
>
> In a pretty big project (~1000 test fixtures) the test fixtures derives from
> a common base class. Because of new requirements I needed to run the tests
> twice, with two different configurations. To accomplish this I used nunit's
> feature "Parameterized test fixture" and declared two testfixture attributes
> on the base class. This worked fine, but led to tedious work adding the
> parameterized ctor on all test fixtures.
> I've already done this, but I would have had a lot of easier work if nunit
> would have accepted property injection rather than ctor injection. Also, in
> my opinion, this would have led to cleaner test fixtures with no
> "disturbing", explicit ctor (even though I must say that I'm
> 100% favoring ctor injection rather than accessor injection in "normal"
> code).
>
> Are there any plans to implement something like this in nunit?
>
> Regards
> Roger
>
> --
> You received this message because you are subscribed to the Google Groups
> "NUnit-Discuss" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/nunit-discuss/-/5eO8rtPKgJAJ.
> To post to this group, send email to [EMAIL PROTECTED]
> To unsubscribe from this group, send email to
> [EMAIL PROTECTED]
> For more options, visit this group at
> http://groups.google.com/group/nunit-discuss?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"NUnit-Discuss" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/nunit-discuss?hl=en.