Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2007

Tip: Looking for answers? Try searching our database.

JUnit Question

Thread view: 
martinmk - 26 Nov 2007 18:06 GMT
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
Hunter Gratzner - 26 Nov 2007 18:19 GMT
> Hi All,
>
> Is it feasible to test already compiled source file with JUnit?

Yes, that's JUnits normal mode of operation.

> I do not know how to
> do that with JUnit.

Read the JUnit documentation.
Alex - 26 Nov 2007 18:52 GMT
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
Lew - 26 Nov 2007 23:53 GMT
> As usual. (Use Eclipse, it does it automatically):
>
[quoted text clipped - 7 lines]
>
> }

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.

Signature

Lew



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.