How to run a junit test?

Hi,
i have compliled a junit test class (MsgQueueTest extends TestCase). When i try to run it, i get:
kostas@home:~/programming/java/SwarmTests/src$ java MsgQueueTest
Exception in thread "main" java.lang.NoClassDefFoundError: junit/framework/TestCase
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)I have tried some parameters, but no luck so far. Any ideas?

Append junit.jar to your CLASSPATH.

Similar Messages

  • How to run the Hardware test on a Mac mini 2015 ?

    how to run the Hardware test on a Mac mini 2015 ?

    Welcome to Apple Support Communities
    New Macs come with Apple Diagnostics instead of Apple Hardware Test, but their purpose is the same: check that your Mac's hardware is working properly. See -> https://support.apple.com/kb/PH18765?locale=en_US
    To run it, you only have to hold down the D key while your Mac is starting up, and follow the steps.

  • Unable to run ADFBC JUNIT Test Classes with JDEV11G 11.1.1.6

    Dear All,
    I upgraded my project to the latest release JDEV 11G 11.1.1.6
    Previously we are on JDEV 11G 11.1.1.5
    I have a JUNIT class that I am running which test my ADFBC components.
    public class MyTestClass {
      @Test
      public void testVOAccess()
        //assertions
    }Unfortunately, I am hitting an error like this from the messages.
    Mar 9, 2012 1:28:07 PM oracle.adf.share.ADFContext getCurrent
    WARNING: Automatically initializing a DefaultContext for getCurrent.
    Caller should ensure that a DefaultContext is proper for this use.
    Memory leaks and/or unexpected behaviour may occur if the automatic initialization is performed improperly.
    This message may be avoided by performing initADFContext before using getCurrent().
    For more information please enable logging for oracle.adf.share.ADFContext at FINEST level.
    Mar 9, 2012 1:28:08 PM oracle.security.jps.internal.config.xml.XmlConfigurationFactory initDefaultConfiguration
    SEVERE: org.xml.sax.SAXParseException: Invalid encoding name "Cp1252".
    Mar 9, 2012 1:28:10 PM oracle.mds
    NOTIFICATION: PManager instance is created without multitenancy support as JVM flag "oracle.multitenant.enabled" is not set to enable multitenancy support.
    Mar 9, 2012 1:28:12 PM oracle.security.jps.internal.config.xml.XmlConfigurationFactory initDefaultConfiguration
    SEVERE: org.xml.sax.SAXParseException: Invalid encoding name "Cp1252".
    Mar 9, 2012 1:28:12 PM oracle.adf.share.jndi.ReferenceStoreHelper getReferencesMapEx
    WARNING: Incomplete connection reference object for connection:MYDATASOURCEAt the JUNIT Test Runner, I see this.
    java.lang.ExceptionInInitializerError: null
         java.lang.reflect.Constructor.newInstance(Constructor.java:513)
         org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:171)
         org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:216)
    Caused by: oracle.jbo.DMLException: JBO-26061: Error while opening JDBC connection.
         oracle.jbo.server.ConnectionPool.createConnection(ConnectionPool.java:207)
         oracle.jbo.server.ConnectionPool.instantiateResource(ConnectionPool.java:166)To validate the issue, I tried to run my same project using the older release which is JDEV 11G 11.1.1.5
    and I see that I am not hitting any error. All my test classes runs fine.
    Has anybody replicated this?
    Thanks

    Didier Laurent wrote:
    I logged the following bug for this issue:
    bug 14030895 - REGR: JDEVELOPER 11.1.1.6.0 JUNIT JBO-26061 ERROR WHILE OPENING JDBC CONNECTION
    Regards,
    Didier.So its really a bug..
    I abandon this already since I cannot find any solution to look up for this.
    On the other hand, I am maintaining two jdeveloper version just to get around this problem.
    When testing ADFBC, I used the 11.1.1.5 while for non-junit test I used the 11.1.1.6
    Hopefully this gets fixed on the next release as I am having a hard time swithcing between two JDev version.
    Thanks
    Edited by: Neliel on May 3, 2012 11:42 PM

  • MacMini 2010 4,1 how to run Apple Hardware Test from  /System/Library/CoreServices/.diagnostics folder

    I have a 2010 Mac Mini4,1 with SnowLeapard and plan to upgrade to Mavericks, but can't run Apple Hardware Test from my applications disk 2 that came with the machine.  For some reason the Mac can read it and kicks it our after about a minute.  Seems to be able to reado other disks, so this one may be corrupted. I found info on this community that says that the AHT is on the hard disk and I found it here /System/Library/CoreServices/.diagnostics using terminal.  When open that folder using terminal it open a window with that folders contents.  My problem is I can execute the only unix executable in that  folder.  It responds with "No application knows how to open /System/Library/CoreServices/.diagnostics/diags.efi"
    Can someone help me out here or if there is downloadable somewhere on line that I can get?

    My 2010 4,1 Mac Mini still has the HW Test on the Internal HD after updating it to Lion, Mountain Lion and Mavericks.
    see > Using Apple Hardware Test
    Additionally if your using a wireless keyboard and it is not invoking the Hardware Test using the D key immediately after the chine, then you may need to use a USB keyboard. Adding that any Apple, PC or generic Logitech USB keyboard should work for invoking the startup commands. 

  • How to run apple hardware test with no cdrom?

    My MacBook Air won't recognise old or new hard drive and I believe I may have a logic board issue. My external CDROM has also just stopped working due to the wire being split some. I have two questions, can I get a replacement wire for the CDROM and can I run Mac hardware test on my 2008 MacBook Air without a CDROM? I still have the original CD1. I am currently booting the mac from a Lion installation on an external HDD attached to the USB port.
    If the answer to those is no, where can I sell this stuff for scrap?
    Thanks

    See this article

  • IMac intel late 2006, lost DVDs, how to run apple hardware test

    Hello, Applers,
    I have an iMac intel core 2 duo late 2006. I have upgraded it to snow leopard. From two months ago, it began to show distorted pictues, random lines/pixels/, and regular freezing. But if I boot it into the safe mode, it works well, although there is no sound or webcam. I did a research online and it seems that I should run apple hardware test (AHT) first. But the DVDs came withi this machines have been lost. where can I download this software? I would greatly appreciate your help if any of you who also have this model of machine and would like to lend me your DVDs.
    any suggestions are welcome.

    You can purchase replacements from AppleCare:
    Apple Store Customer Service at 1-800-676-2775 or visit online Help for more information.
    To contact product and tech support visit online support site.
    There is no way to run the AHT without the discs.
    If it works OK in safe mode then you might think about:
    Resetting your Mac's PRAM and NVRAM
    Intel-based Macs: Resetting the System Management Controller (SMC)
    Reinstall Snow Leopard:
    Reinstall OS X without erasing the drive
    Do the following:
    1. Repair the Hard Drive and Permissions
    Boot from your Snow Leopard Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities menu. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    2. Reinstall Snow Leopard
    If the drive is OK then quit DU and return to the installer.  Proceed with reinstalling OS X.  Note that the Snow Leopard installer will not erase your drive or disturb your files.  After installing a fresh copy of OS X the installer will move your Home folder, third-party applications, support items, and network preferences into the newly installed system.
    Download and install the Combo Updater for the version you prefer from support.apple.com/downloads/.

  • How to run a particular test from a set of CodedUI tests?

    Hi,
    I have designed custom framework from which we can decide which test case needs to be run or not. When I mark a test case as Yes (which means this testcase needs to be execute), how can i execute only those test case alone from Visual Studio?
    Here, I have created the test scripts for all the above test cases in a single CodedUI test file and i need to execute the TC_0003 as i marked the Run as Yes only for TC_003 in the framework. Can you please help me to do the same?
    Thanks  in Advance
    Selvaraj C
    Selvaraj

    Hi Selvaraj,
    >> I have designed custom framework from which we can decide which test case needs to be run or not. When I mark a test case as Yes (which means this testcase needs to be execute), how can i execute only those test case alone from Visual Studio?
    Do you mean you want to execute the special test? As far as I know, Ruby provides a framework in its standard library for setting up, organizing, and running test called Test::Unit. Test::Unit provides the function that running single tests. The link below
    shows the details:
    # Ruby Programming/Unit testing
    http://en.wikibooks.org/wiki/Ruby_Programming/Unit_testing
    I am not sure what do you mean by “custom framework”, do you want to design custom framework? In my option, it seems to be much complex. The steps below might be useful to you:
    1. Store the tests in a csv file, and query the test which need to execute from the csv file, for this, you could turn to the link:
    https://social.msdn.microsoft.com/Forums/en-US/9664862a-4302-4754-a915-2beceff364d5/how-to-stop-sequential-execution-of-data-driven-method-in-coded-ui
    2. Get the test name, and execute the test from the command-line. The link below shows the details about the command-line:
    # MSTest.exe Command-Line Options
    https://msdn.microsoft.com/en-us/library/ms182489(VS.100).aspx
    3. Write a script to run the command-line
    If I misunderstood you, please feel free to let me know.
    Best Regards,
    Edward
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

  • Running a JUnit test case using Ant in Eclipse

    If I have a "JUnit", how can I run it using "Ant" in Eclipse?
    Thanks.

    Right-click on the ant build script and select "Run as ant build". But why bother? Eclipse has its own JUnit runners

  • How to run Apple Hardware Test on Mac Pro with ML preinstalled?

    I have Mac Pro 5.1 (2012) which came with Mountain Lion preinstalled. It didn't have install DVDs. How do I run AHD? Restarting with D, or command+D, or option+D didn't work. It would just restart the OS. And Mac Pro didn't support Internet AHD eather.

    Thank you for your reply, Carolyn.
    I read this article. None of those applied to my case:
    my Mac Pro came before 2013 and it doesn't have Apple Diagnostics  built into it,
    it doesn't have Apple Hardware Test built into it,
    and my Mac Pro came with Mountain Lion preinstalled and it did not have system software disc or USB flash drive.
    Restarting while holding down the D key simply doesn't work it just reboot back to the desktop.

  • How to structure your junit test folder ?

    Hi,
    I just would like to ask the forum community about the pro and cons of test folder structure. Some developers would argue that it is okay to put your test source code inside your application code source code. Example:
    src
    |--com
    .....|----xyz
    ............|----SomeClass.java
    ............|----SomeClassTest.java     
    But some developers prefer to put their test code outside the source folder:
    src
    |----com
    .......|------xyz
    .................|---SomeClass.java
    test
    |-----com
    .......|----xyz
    ..............|-----SomeClassTest.java     
    I usually roll with the second approach, because I do not want to clutter my source code with the test code. This will also make deployment easier. But I would like to know what other people think about it. What are the pro and cons of these 2 different approach.
    Thank you. Your feed back is grea
    Edited by: inoel131081 on Jul 4, 2008 5:14 PM

    I also use the separate src-test folder
    so i can clearly see what the coverage is of my source only without the coverage from my tests
    so i can do an export from my source only
    so in general because the tests are not really part of the project

  • JUnit Tests (How To) - Websphere/Eclipse

    I'm about to start looking into using JUnit to test some db resultset timings. As I haven't really dived into this before, I'm looking for some guidance.
    Can someone post an example of how I would use JUnit to test the timing of a resultset or the timing of a procedure.
    I could just do a simple timed test, but I want to start using JUnit.
    Where:
    <start timing>
    do a bunch of really wild stuff
    <end timing>
    Thanks.

    JUnit isn't meant for performance timing. There's nothing to stop you from doing it, of course.
    JUnit might be pertinent if you had a metric that would define success or failure of your "really wild stuff".
    But timing would be more the province of JMeter or another performance measurement tool.
    With that said, Eclipse handles JUnit tests easily. Just have the JUnit JAR in your project's build path. Open the debug view and you can run any JUnit test in your project.
    I have an Ant build.xml that runs all the tests in my projects automatically and generates reports for viewing in a Web browser. That's a great way to go, IMO.

  • Writing JUnit test app to test a method which uses AppResources

    Recently I was given a requirement to write a JUnit class( with main) to test a method in a Processor class which is running in weblogic. But this method in processor class makes use of AppResources like this: AppResources appResources = new AppResources("ApplicationResources"); String ruleFileName = appResources.getResourceString("rule.file.irlfile"); But when I try to run my JUnit test (stand alone app with main class) I am getting "java.util.MissingResourceException: Can't find bundle for base name ApplicationResources" exception. The appResources is null... Any ideas how to work around this problem?

    It doesn't sound like the Process class was designed for testability outside of its J2EE server container, probably. So writing a unit test for it, under its current design, may be an exercise in futility. You might want to look into "Cactus" tests (search for JUnit Cactus on the web), to test it in its container. Or, redesign the class for testability, separating its business logic better (that's a lot of work to do though) so that it can be instantiated and exercised independently of its environment.

  • JUNIT test failure-Configuration file bc4j.xcfg not found in the classpath

    Hi All,
    As part of an ESS project,Im having a model project containing a VO(parameters VO).This VO is configured to have Read-only access through SQL query and have only one transient attribute each.For the model projects containing the VO for pre merge checker compliance I had to create JUNIT Test projects containing new AMs for testing the parametersVO. While running the JUNIT tests I got an exception like
    “oracle.jbo.JboException: JBO-29000: Unexpected exception caught: oracle.jbo.ConfigException, msg=JBO-33001: Configuration file /oracle/apps/hcm/goals/core/dataMigration/publicEssModel/test/applicationModule/common/bc4j.xcfg is not found in the classpath.”.—even though this file is contained in both the src/classes folder of the project.
    When i try to run the TestAM I'm getting an exception like 'configuration tester.xcfg not found in the calsspath.
    While debugging this error, we found that we are able to successfully run the JUNIT tests if we make some changes in the adf-config.xml file of the Application. The change required is to comment out the mdsC:adf-mds-config tag in the xml file.
    After doing this change Im also able to run my AM without any exception.
    Is this a known issue?.
    Since modifying the adf-config.xml is not a recommended practice is there any workaround that we can get rid of this exception.
    Regards,
    Ajin.

    Just checked but could only find this thread Unable to run ADFBC JUNIT Test Classes with JDEV11G 11.1.1.6
    As it's also dealing with junit and 11.1.1.6.0 you might want to read it.
    Timo

  • Best practice for @EJB injection in junit test (out-of-container) ?

    Hi all,
    I'd like to run a JUnit test for a Stateless bean A which has another bean B injected via the @EJB annotation. Both beans are pure EJB 3 POJOs.
    The JUnit test should run out-of-container and is not meant to be an EJB client, either.
    What is the easiest/suggested way of getting this injection happening without explicitely having to instantiate the bean B in my test setup ?

    you can deal with EntityBeans without having the Container managed senario , you can obtain instance of EntityManager using the "EntityManagerFactory" and providing the "persistence.xml" file and provide the "provider" (toplink,hibernate ,...), then you can use entities as plain un managed classes

  • How to run a test suite in JUnit?

    I am newbie to JUnit. I am running JUnit 4 in eclipse 3.2.1. I have created test cases in a package called "testsuite". Moreover, I have created a test suite in the same package to run these test cases.
    Sample code for a test case:
    package testsuite;
    import junit.framework.TestCase;
    import org.junit.Before;
    import org.junit.Test;
    import system.NodeItem;
    public class NodeItemTest extends TestCase {
        NodeItem aNode;
        @Before
        public void setUp() throws Exception {
            aNode = new NodeItem();
            aNode.setMinTempTherm(2);
        @Test
        public void testSetMinTempTherm() {
            assertEquals(2, aNode.getMinTempTherm());
    Sample code for the test suite I have created to run this case and another one:
    package testsuite;
    import junit.framework.Test;
    import junit.framework.TestSuite;
    public class AllTests {
        public static Test suite() {
            TestSuite suite = new TestSuite("Test for testsuite");
            //$JUnit-BEGIN$
            suite.addTestSuite(CommunicationTest.class);
            suite.addTestSuite(NodeItemTest.class);
            //$JUnit-END$
            return suite;
    The problem is:
    When I run the test cases separetly, everything runs without any problems, but when I try to run the test suite I get the follwing ERROR:
    In the Failure Trace window I get *"java.lang.Exception: No runnable methods".*
    In the other winodw if I double click the error, a dialog pop up which says *"Method 'testsuite.AllTests' not found. Openning the test class"*.
    I have followed some tutorials to reach the point I am at now. Please help me proceed.
    Thanks in advance.

    I didn't know I don't have to extend. Here is how I modified the code after your advace and it worked. Any other good advaces?
    package testsuite;
    import static org.junit.Assert.assertEquals;
    //import junit.framework.TestCase;
    import org.junit.Before;
    import org.junit.Test;
    import system.NodeItem;
    public class NodeItemTest /*extends TestCase*/ {
         NodeItem aNode;
         @Before
         public void setUp() throws Exception {
              aNode = new NodeItem();
              aNode.setMinTempTherm(2);
         @Test
         public void testSetMinTempTherm() {
              assertEquals(3, aNode.getMinTempTherm());
    package testsuite;
    import org.junit.runner.RunWith;
    import org.junit.runners.Suite;
    //import junit.framework.Test;
    //import junit.framework.TestSuite;
    @RunWith(Suite.class)
    @Suite.SuiteClasses({
         CommunicationTest.class,
         NodeItemTest.class,
    //    TestClass3.class
    public class AllTests {
    //     public static Test suite() {
    //          TestSuite suite = new TestSuite("Test for testsuite");
    //          //$JUnit-BEGIN$
    //          suite.addTestSuite(CommunicationTest.class);
    //          suite.addTestSuite(NodeItemTest.class);
    //          //$JUnit-END$
    //          return suite;
    }Thanks again!

Maybe you are looking for

  • How can i add one month to a date variable ?

    Unlike the week which always 7 days, month may change from 28 to 31, so how can i add one month to a date variable ? Thanks in advance.

  • ALV Tree - Excel & header comment

    Hello, I want to export to excel my ALV tree. I'm using the FM 'ALV_XXL_CALL'.  But I would like to set the header comment from the ALV in the excel sheet (before the data). How I have to do ? Thank you Bernard Pochin.

  • Extraction from SD to BW

    Hi Friends, i'm on a new project. Now, I have to create an open hub destination in version 3.x. It has to be fulfilled with SD Data. And that's the matter. I don't know anything about extracting data from SD. Anybody has documentation about it? Thank

  • How do i close apps i used to to double click home button

    how do i close apps i used to to double click home button

  • Between custom tag and scriptlets

    Hi, Is it possible to choose between executing a custom tag or a scriptlet based on a jsp variable? I mean to do something like-- <% if(condition is true) custom tag execution else some normal jsp code continue after if %>