• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

junit and requirements

 
Lara McCarver
Ranch Hand
Posts: 118
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My exam has the following line:

The final program must have no dependencies on any libraries other than those of the Java 2 Platform.


Does this mean that I can't turn in a project which includes junit modules for testing? Of course it is possible to put all my junit tests in separate packages and then not include those packages in the code that I give to Sun. Though normally people recommend that you keep the tests with the classes. So your data package includes:

Data.java
DataTest.java
LockManager.java
LockManagerTest.java
RecordLock.java
RecordLockTest.java
HomemadeDB.java
HomemadeDBTest.java
etc.

By the way, Reza ( Hi ) I have figured out how to use junit for some of the multi-threaded testing I am going to do. You have your junit test method create a monitoring thread which can receive notification of important events, then you create and start the threads you need for your test. Each thread does its thing while notifying the monitor of its events. The monitor thread waits for the other threads to complete all of their expected events, then evaluates whether everything happened correctly, and finally notifies the test method that its done. The test method which created all these threads waits for notification of completion from the monitor thread.

So far, I only have 1 small test, mostly as proof of concept. I create 2 threads. Each thread does a lock() on record 2, goes to sleep for 1 second and then does an unlock() on record 2.
 
John Smith
Ranch Hand
Posts: 2937
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does this mean that I can't turn in a project which includes junit modules for testing?

That would be risky. The assessor may want to compile your code, and he/she may not have junit.jar. Even if you include it with your submission, I think it would be unreasonable to expect him/her to put it in the classpath. Keep the tests for yourself, give 'em what they want.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic