Re: NUnit tests: Generalization of tests using class factory?

"Laimonas Simutis" <[email protected]> Thu, 4 Sep 2008 17:05:35 -0500
Newsgroups gmane.comp.windows.dotnet.nunit.user
Message-ID <[email protected]>
Yes, it is possible.

For instance, in our data access tests to test basic CRUD
functionality of entity objects we wrote a generic test class that
looks something like this:

public abstract class EntityDataTests<T, EntityDataServiceType>
{
    [Test]
    public void Save_Select_Delete_Test()
    {
        T o = this.CreateObject();

        Assert.IsNull(entityService.SelectOne(o.Id);

       entityService.Save(o);

       // select again with test or whatever

       entityService.Delete(o);

       // test for it not being there
    }
}

We had I think a total of 5-6 generic tests like that. Then you write
a specific test class that inherits from this abstract class. Without
writing anything you can test its basic database behavior and if you
need anything more specific, you do it in that specific test class.




On Thu, Sep 4, 2008 at 4:55 PM, Mr. Delphi Developer
<[email protected]> wrote:
> We are building Business Object Classes and Data Object Classes and would
> like to build NUnit tests for each of them, However, instead of having tons
> of redundant code, we'd like to "genericize" our test suite where we could
> possibly use a class factory to help out.
>
> Has anyone done this kind of thing before? Is it possible to do this?
>
>
>
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Nunit-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/nunit-users
>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/