You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Kamal Ahmed <KA...@webMethods.com> on 2006/02/06 18:05:40 UTC
junit for set Method with boolean input and void return
Hi,
I am a bit confused here, so I would appreciate a little help.
I am trying to write a test for method:
public final void setAcceptMatch(boolean inMatchFlag)
{
acceptMatch = inMatchFlag;
}
And here is what I have so far:
public void testsetAcceptMatch() {
WmLoggerFilter subjectWmLoggerFilter = new
WmLoggerFilter();
subjectWmLoggerFilter.setAcceptMatch(true);
}
Now, which assert method should I use to see if "acceptMatch" is true or
not.
Thanks,
-Kamal.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: junit for set Method with boolean input and void return
Posted by Curt Arnold <ca...@apache.org>.
On Feb 6, 2006, at 11:05 AM, Kamal Ahmed wrote:
> Hi,
>
> I am a bit confused here, so I would appreciate a little help.
> I am trying to write a test for method:
>
> public final void setAcceptMatch(boolean inMatchFlag)
> {
> acceptMatch = inMatchFlag;
> }
>
> And here is what I have so far:
>
> public void testsetAcceptMatch() {
>
> WmLoggerFilter subjectWmLoggerFilter = new
> WmLoggerFilter();
>
> subjectWmLoggerFilter.setAcceptMatch(true);
> }
>
> Now, which assert method should I use to see if "acceptMatch" is
> true or
> not.
Typically, you would do something like:
assertTrue(subjectWmLoggerFilter.getAcceptMatch());
If there wasn't a "get" method for the property, then you could
construct a scenario where you could observe the expected change in
behavior.
p.s. These questions might be better asked on a junit mailing list or
by picking up a unit testing book.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org