JUnit Question

M

martinmk

Hi All,


Is it feasible to test already compiled source file with JUnit? A task
was given to me to test the bytecode (.class file) without having the
source code. I do have the API docs and based on that I can come up
with oracles to determine the expected outcome. I do not know how to
do that with JUnit.

Thanks a million
 
A

Alex

As usual. (Use Eclipse, it does it automatically):

public class RandomIntTest extends TestCase {

public void testNextInt() {
int one=random.nextInt();
int two=random.nextInt();
assertFalse("Two random ints are equal "+one+"="+two, one==two);
}

}
-- Alex
 
L

Lew

Alex said:
As usual. (Use Eclipse, it does it automatically):

public class RandomIntTest extends TestCase {

public void testNextInt() {
int one=random.nextInt();
int two=random.nextInt();
assertFalse("Two random ints are equal "+one+"="+two, one==two);
}

}

The problem with this particular test is that two consecutive random ints can
legitimately be equal.

A good pseudorandom generator will be no more prejudiced against a second
value equal to the first than any other second value.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top