• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

junit and requirements

 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic