Aum Tao

Ranch Hand
+ Follow
since Feb 14, 2006
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Aum Tao

I am familiar with the basic usage of jUnit and have integrated it with Eclipse to gain a working knowledge. But, I would appreciate if someone can answer the following doubts that I came across during my jUnit testing.

I was testing a String multiplier class with a multiply() method that takes 2 numbers as inputs (as String) and returns the result number (as String)

I have done the implementation and created a test class with the following test cases involving the input String parameter as
1) valid numbers
2) characters
3) special symbol
4) empty string
5) Null value
6) 0
7) Negative number
8) float
9) Boundary values
10) Numbers that are valid but their product is out of range
11) numbers will + sign (+23)

1) I'd like to know if "each and every" assertEquals() should be in it's own test method? Or, can I group similar test cases like testSpecialCharactersArguments() to contains all asserts involving special characters?

2) If testing an input value like character ("a"), do I need to include test cases for ALL scenarios?
"a" as the first argument
"a" as the second argument
"a" and "b" as the 2 arguments

3) As per my understanding, the benefit of these unit tests is to find out the cases where the input from a user might fail and result in an exception. And, then we can give the user with a meaningful message (asking them to provide valid input) instead of an exception. Is that the correct? And, is it the only benefit?

4) Are the 11 test cases mentioned above sufficient? Did I miss something? Did I overdo? When is enough?

5) Following from the above point, have I successfully tested the multiply() method?

Thanks for your input.
13 years ago
You should have a look at ServletsFAQ

If it's an IDE specific question, you are better off posting it in the IDE forum.
[ December 20, 2008: Message edited by: Prateek Parekh ]
15 years ago
Well done, Karthik.
15 years ago
Please UseCodeTags
And, you cannot cast an Object to a UserTransaction class.
15 years ago

Originally posted by Casttro Francis:
Yes you can follow mastering EJB3 book. But my option for beginners is EJB3 in Action..

Please read
EaseUp and

Could you provide some more details?
15 years ago
Since you seem to be new to EJB, it would be better if grab a book like "EJB 3.0 in Action" to understand these concepts. It won't be possible to describe these concepts in a few lines to a newbie.
The keyword final ensures that the reference to the Integer[] cannot point to another Object array. Note, that it doesn't stop you from changing the contents of the array.

The keyword static ensures that the reference is shared among all the instances.
Could you provide more details? Also, read ShowSomeEffort and UseMeaningfulSubjectLine

[ December 10, 2008: Message edited by: Prateek Parekh ]
[ December 10, 2008: Message edited by: Prateek Parekh ]
15 years ago
Although, frameworks like Spring are getting more popular due to features like Dependency Injection and AOP, you will still need to understand the fundamentals of EJB 3.0 in order to develop business components. They will help you learn other frameworks too. So, it wouldn't be a waste of time to prepare for SCBCD. If you had been preparing for EJB 2.0, I would have advised against it since it was excessively complex and involved lots of code even to develop the most rudimentary applications.
You will understand it better if you think of it as an OR operator, except that it will return false even when both the conditions are true.

returns false because both conditions evaluate to true i.e. 2 < 3 is true
and so is 4 > 3
How about the Design patterns book from Gang of Four "Design Patterns: Elements of Reusable Object-Oriented Software".

And, there is also the Head First Design Pattern book, which is an easy read.

How come when swiffer(aa) is run, a 4 is produced instead of a 1?

Note that you are creating an array of A, but not initializing the individual elements of the array. Therefore, it is treated as an Object and 4 is displayed when

is executed.

Similarly, you are only creating one array object ba[], but not initializing the individual elements. Therefore,

is executed and 3 is displayed.

Finally, as you mentioned, sifter(7) gets boxed to an Integer and widened to an Object to display 4.

Also, I would like to add that in order for this example to behave the way you had expected, you would have to do something like

[ December 10, 2008: Message edited by: Prateek Parekh ]
15 years ago