This is a bit long story,
We are developing client-server application based on entities. So, there is
an entities infrastructure and there are business entities itself.
The infrastructure serves more than project, business entities are specific
per project.
The infrastructure must be unit tested, but for that we need entities to
work with. No business entities are good, because they are application
specific and we want the infrastructure and its unit tests to be completely
and utterly decoupled from any application.
So, I developed a dummy entity, which is a generic type with the parameter
being just a tag type. There is a set of entity features I want to test and
I can generate a new dummy entity type to match specific set of features.
This allows me to write numerous unit tests which operate on dummy entities
and unit test the various aspects of the entities infrastructure.
Until now all is good - there is entities infra, dummy entities and unit
tests which utilize dummy entities to test the framework.

Now comes an application using our framework. Someone has developed a
business entity. This entity must be a good citizen with respect to the
entities framework, in addition to supporting application specific features.
So, the unit tests for a business entity can be divided into two categories:
1. The ones that make sure the entity plays well with the entities
framework, i.e. does not break any basic functionality.
2. The ones that test the application specific logic.

My use case concerns the first category. I want to save the developer the
task of writing these unit tests, because they are the same as the ones
already written for dummy entities. The only difference is that they operate
on a specific business entity and not the dummy ones.

My solution is that the test fixture for the specific business entity will
examine the test fixture for the dummy entities and generate dynamic unit
tests based on the statically compiled ones found in the dummy entity test
fixture. Thus the developer will get the unit tests that make sure the
particular business entity is a good citizen with the entities framework for
free.
Of course, the second category unit tests will have to be implemented
manually.

To implement the solution, I reflect on the dummy entities test fixture,
recognize a test method and create a new test invoking the found method.
Every dummy entity test method has a factory and receives an instance of
IEntityContext as the first parameter. The dummy entity unit test factory
may produce numerous instances of this interface to yield unit tests that
cover different types of dummy entities. The dynamically generated unit
test, on the other hand, will pass an IEntityContext instance corresponding
to the specific business entity. This way, the same unit test code is
reused.

There is a problem with those dummy entity unit tests, which receive more
parameters in addition to the IEntityContext instance. Unfortunately, I do
not know how to produce dynamic test to invoke them, so the developer will
have to manually create a test method and delegate from there to the
respective dummy entity unit test method passing the right parameters. I
have asked already on the group is it possible to create a dynamic
combinatorial test. This is in order to attempt and create dynamic tests
corresponding to a family of dummy entity unit tests having more than one
parameter, but following a well defined scheme.

Anyway, this is the short version of the story. Hope I have expressed myself
clearly.
Regards,

On Thu, Aug 20, 2009 at 7:09 AM, Jeff Brown <[email protected]> wrote:

>
> It is sort of possible but pretty sophisticated.
>
> What's your use-case?
>
> Jeff.
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On
> Behalf Of Mark Kharitonov
> Sent: Wednesday, August 19, 2009 1:58 PM
> To: MbUnit.User
> Subject: MbUnit How to reflect on a test fixture type in terms of test
> cases?
>
>
> Hi.
>
> I have a test fixture type. I would like to perform high level reflection
> on
> it, meaning I would like to operate not with MethodInfo objects, but with
> the respective test cases, like the TestCase class.
> In other words, I would like to be able to write something like this:
>
> foreach (var testCase in GetTestCases(typeof(SomeTestFixture)))
> {
> }
>
> I am perfectly fine with only the statically compiled test cases
> corresponding to the methods attributed with the TestAttribute.
>
> Is it possible?
>
> Thanks.
>
>
> >
>


-- 
Be well and prosper.
==============================
"There are two kinds of people.Those whose guns are loaded and those who
dig."
  ("The good, the bad and the ugly")
So let us drink for our guns always be loaded.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MbUnit.User" 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/mbunituser?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to