Results 1 to 6 of 6
Thread: Junit Testing Boolean methods
- 04-12-2013, 12:37 PM #1
Senior Member
- Join Date
- Mar 2013
- Posts
- 123
- Rep Power
- 0
- 04-12-2013, 12:42 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
Re: Junit Testing Boolean methods
You woudl write test cases that would check that setHasPower returns the correct value for different situations.
So if running another method on the object should change hasPower to 'true' then you would add an assert check that comfirms that.
It's not the sort of method that can be checked by itself.Please do not ask for code as refusal often offends.
** This space for rent **
- 04-12-2013, 12:52 PM #3
Senior Member
- Join Date
- Mar 2013
- Posts
- 123
- Rep Power
- 0
Re: Junit Testing Boolean methods
can you give me an example?
- 04-12-2013, 01:28 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
Re: Junit Testing Boolean methods
Without knowing the class you are testing, no.
And even with it, what about my description is confusing?
If all this class is is a model class consisting solely of setters and getters I, personally, wouldn't test it.Please do not ask for code as refusal often offends.
** This space for rent **
- 04-12-2013, 02:24 PM #5
Senior Member
- Join Date
- Mar 2013
- Posts
- 123
- Rep Power
- 0
Re: Junit Testing Boolean methods
I was wondering if you could show me a skeleton of a Junit testcase for these examples please:
a method that tests 5 cards and finds a pair (poker)
a method that adds 2 numbers together
a method that tests 5 cards and finds 4 of kind (poker)
like a basic outline. I dont know where to start..
- 04-12-2013, 02:30 PM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 29
Similar Threads
-
JUnit Testing enQueue & deQueue Methods
By Martyn in forum New To JavaReplies: 1Last Post: 01-10-2013, 01:25 AM -
Junit testing, testing list<e> interface
By mackavelirip in forum New To JavaReplies: 0Last Post: 10-05-2011, 07:08 AM -
JUnit testing
By hedonist in forum Advanced JavaReplies: 4Last Post: 10-04-2009, 01:06 PM -
Help with testing methods and classes in JUnit, using BlueJ
By Jonasse in forum New To JavaReplies: 1Last Post: 04-17-2008, 03:30 PM -
Testing JUnit PDE with Ant
By keynan in forum EclipseReplies: 0Last Post: 02-15-2008, 12:35 AM
Bookmarks