RFC: Unit tests simplification

0 views
Skip to first unread message

Sebastien Pouliot

unread,
Jan 14, 2008, 5:11:55 PM1/14/08
to Gendarme
Hello,

Daniel, from GHOP, contributed quite a few rules recently. He also had
some ideas around how unit tests could be simplified - and I didn't
hesitate a bit to create him a task to do just that ;-)

Here are the details...
http://code.google.com/p/google-highly-open-participation-mono/issues/detail?id=75

Any comments ?

Thanks,
Sebastien

Néstor Salceda

unread,
Jan 15, 2008, 3:05:56 PM1/15/08
to gend...@googlegroups.com
Hola Sebastien,

On lun, 2008-01-14 at 14:11 -0800, Sebastien Pouliot wrote:
> Hello,
>
> Daniel, from GHOP, contributed quite a few rules recently. He also had
> some ideas around how unit tests could be simplified - and I didn't
> hesitate a bit to create him a task to do just that ;-)

Cool! I have reviewed the files, and it's a good work.

Yes, first of all, sorry for the delayment answering the e-mail. I
have just finished my first exam now.

Second, my 2 cents:

* public abstract class MethodRuleTest<TMethodRule>
where TMethodRule : IMethodRule, new ()

I like a lot this code.

* About the AssertSuccess or AssertFailure methods, I would like name
that methdos as "AssertRuleSuccess" or "AssertRuleFailure". IMHO is more
concrete and we will improve the test readability.

* The others "Assert[Success | Failure]" with MessageType as parameter,
perhaps would be a better name "AssertMessageType" or "AssertMessage".

* And the same for the expectedCount one, other name could be
"AssertViolationsCount".

And that's all, what do you think about the suggestions?

Good work! :)

Néstor.

Exception

unread,
Jan 15, 2008, 4:03:51 PM1/15/08
to Gendarme
Hi, I updated the sources but just noticed your comment.

> * About the AssertSuccess or AssertFailure methods, I would like name
> that methdos as "AssertRuleSuccess" or "AssertRuleFailure". IMHO is more
> concrete and we will improve the test readability.
>

Okay, I'll fix that.

> * The others "Assert[Success | Failure]" with MessageType as parameter,
> perhaps would be a better name "AssertMessageType" or "AssertMessage".
>
> * And the same for the expectedCount one, other name could be
> "AssertViolationsCount".
>

I'm not sure it's neccessary. These are all _overloads_ so you can
check for a failure in one line - both if you also need to check for
messages count/type and if you needn't.


> Good work! :)

Thanks!

Dan.

Sebastien Pouliot

unread,
Jan 16, 2008, 9:31:49 AM1/16/08
to Gendarme
Hola Néstor,

On Jan 15, 3:05 pm, Néstor Salceda <nestor.salc...@gmail.com> wrote:
> Hola Sebastien,
>
> On lun, 2008-01-14 at 14:11 -0800, Sebastien Pouliot wrote:
>
> > Hello,
>
> > Daniel, from GHOP, contributed quite a few rules recently. He also had
> > some ideas around how unit tests could be simplified - and I didn't
> > hesitate a bit to create him a task to do just that ;-)
>
> Cool! I have reviewed the files, and it's a good work.
>
> > Here are the details...
> >http://code.google.com/p/google-highly-open-participation-mono/issues...
>
> > Any comments ?
>
> Yes, first of all, sorry for the delayment answering the e-mail. I
> have just finished my first exam now.

No problem, I knew you were busy and I hope everything went fine with
your exam :)

> Second, my 2 cents:
>
> * public abstract class MethodRuleTest<TMethodRule>
> where TMethodRule : IMethodRule, new ()
>
> I like a lot this code.
>
> * About the AssertSuccess or AssertFailure methods, I would like name
> that methdos as "AssertRuleSuccess" or "AssertRuleFailure". IMHO is more
> concrete and we will improve the test readability.

Yes, that would also match better with the other changes that are
planned, like a DoesNotApply return value.

> * The others "Assert[Success | Failure]" with MessageType as parameter,
> perhaps would be a better name "AssertMessageType" or "AssertMessage".
>
> * And the same for the expectedCount one, other name could be
> "AssertViolationsCount".
>
> And that's all, what do you think about the suggestions?

I think that Daniel's overloads should be enough, unless you have some
thing specific in mind ?

> Good work! :)
>
> Néstor.

Good luck with your next exams!
Sebastien

Néstor Salceda

unread,
Jan 16, 2008, 12:54:58 PM1/16/08
to gend...@googlegroups.com
Hey Sebastien,

On mié, 2008-01-16 at 06:31 -0800, Sebastien Pouliot wrote:
> Hola Néstor,

> >
> > Yes, first of all, sorry for the delayment answering the e-mail. I
> > have just finished my first exam now.
>
> No problem, I knew you were busy and I hope everything went fine with
> your exam :)

Thanks you very much :)

> > * The others "Assert[Success | Failure]" with MessageType as parameter,
> > perhaps would be a better name "AssertMessageType" or "AssertMessage".
> >
> > * And the same for the expectedCount one, other name could be
> > "AssertViolationsCount".
> >
> > And that's all, what do you think about the suggestions?
>
> I think that Daniel's overloads should be enough, unless you have some
> thing specific in mind ?

No, I haven't seen those methods as overloads because I'm used to check
first the rule success or failure, after the number of violations and
finally the message types.

Then, with these new methods, I can check all in one line. This 2 last
comments doesn't make sense, sorry.

> Good luck with your next exams!

Thanks you another time :)

Néstor.

Sebastien Pouliot

unread,
Jan 17, 2008, 7:56:34 PM1/17/08
to Gendarme
Much more is available, same bat-url

Please comment!
Sebastien
Reply all
Reply to author
Forward
0 new messages