How to run test cases in a jar file using junit?

Hi,
I want to run test cases in a jar file using junit and the jar file is not in the class path. I wrote the following code, but it does not work.
import java.net.URL;
import java.net.URLClassLoader;
import junit.framework.TestResult;
import junit.textui.TestRunner;
public class MyTestRunner {
     public static void main(String[] args) throws Exception{
          URL url = new URL("file:///d:/case.jar");
          URLClassLoader loader = new URLClassLoader(new URL[]{url});
          loader.loadClass("TestCase1");
          TestRunner runner = new TestRunner();
          TestResult result = runner.start(new String[]{"TestCase1"});
          System.out.println(result.toString());
}Any ideas?
Thanks a lot.

Wouldn't it just be easier to put it on the classpath? You're trying to, anyway, with a URLClassLoader, albeit in an entirely unnecessarily complicated way

Similar Messages

  • How to run .jar on linux & how to create .jar file using java?

    hi, may i know how to run .jar on linux & how to create .jar file using java? Can u provide the steps on doing it.
    thanks in advance.

    Look at the manual page for jar:
    # man jar
    Also you can run them by doing:
    # java -jar Prog.jar

  • How to export test cases into oracle test manager

    hi
    present i am learning this tool help plz
    how to export test cases into oracle test manager
    Edited by: 799636 on Oct 5, 2010 7:11 AM

    Create a script in openScript and save it to a workspace (a shared directory on the OTM server). To add an Oracle OpenScript test to OTM:
    1.Select the Tests tab.
    2.Click the Add button.
    3.Enter a name for the test.
    4.Select Oracle OpenScript in the Type field.
    5.Click Find to display the Select Script dialog box.
    6.Select the Repository and Workspace.
    7.Select the Oracle OpenScript script that you want to add.
    8.Click OK.
    9.Select the owner and priority and enter any descriptive information in the Functionality and Description fields.
    10.Click Save.
    Regards,
    Jamie

  • Run test case from command line

    Hi  All,
    Working environment : VS 2013 professional 
    Project type : Unit test project for (Windows 8.1 and Windows phone 8.1)
    I have a set of unit test cases and want to run it on command line.I tried MSTest.ext and vstest.console.exe for running test case but not succeed.  
    command :  MSTest.exe /testcontainer:path of project dll
    command :  vstest.console.exe path of project dll
    Type of Error
    Error : Unit test case for windows store and windows phone app can't be run outside appcontainer. 
    Error : No tests to execute
    command :  MSTest.exe /testcontainer:path of appx
    command :  vstest.console.exe path of appx
    Error : root certificate error 
    I just want to run windows 8.1 and windows phone 8.1 run test cases from command line.
    Thanks in advance.

    Hi vicky2468,
    Based on your issue, as far as I know that if we want to run unit test for windows store and windows phone app using mstest.exe or vstest.console.exe in command line, you will need to execute the .appx instead of the dll in command line.
    In addition, I tried to run the appx for unit test in command line,
    but I found that I also get the same issue as yours. I could not execute the appx for unit test in command line successfully.  But if we run it with VS IDE in Test
    Explorer windows, it seems that it works fine.
    So I suggest you can submit a feedback for this issue, to get the issue confirmed and diagnose by product team, would you please create connect report for it? You will get email notification for update.
    http://connect.microsoft.com/VisualStudio/feedback/CreateFeedback.aspx
    When you submit the connect, I suggest you can provide your project for product team so that product team will
    be better help you solve this issue.
    If you submit it, please share me the link here, I will help you vote it. I think we could get the latest information
    from the product team experts. Of course, if I get any latest useful information, I will update it here.
    Thanks for your understanding.
    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.

  • How to assign test cases to test catlog

    how to assign test cases(stwb_tc) to test catlog(stwb_2)?

    Hi
         goto to transaction stwb_1 enter the text and you will a get a screen now
    goto to Menu
    EDIT->Nodes->insert->As subnode
    on the selecting you will get the option to add a test case (stwb_tc) or  a test caltalogue.
    Please reward if useful..

  • How to assign test cases to test package?

    how to assign test cases(stwb_tc) to test package(stwb_2)?

    Hi
         goto to transaction stwb_1 enter the text and you will a get a screen now
    goto to Menu
    EDIT->Nodes->insert->As subnode
    on the selecting you will get the option to add a test case (stwb_tc) or  a test caltalogue.
    Please reward if useful..

  • How to assign test cases to test package and test catlog?

    how to assign test cases(stwb_tc) to test package(stwb_2) and test catlog(stwb_1)?

    Hi
         goto to transaction stwb_1 enter the text and you will a get a screen now
    goto to Menu
    EDIT->Nodes->insert->As subnode
    on the selecting you will get the option to add a test case (stwb_tc) or  a test caltalogue.
    Please reward if useful..

  • How to select test cases efficiently for a test package?

    Dear experts,
    I would like to ask you if you have found a way administer how to assign test cases to test packages and test packages to testers. For regression tests this assignment remains relatively stable (often the key users).
    Do you know a way to administer this within the solution manager - or do you recommend the old excel table.

    Hello Ragu!
    Thank you for your answer! My question was regarding the organisational side, I didn't get this clear.
    I know how to generate a test package and how to assign a tester to a test package but where do I get the information which test packages I need and which tester to assign to which package.
    Maybe a good option is to assign the tester as a team member on the process step level. Thus the assignments can be listed with SOLAR_EVAL using "Assignments / Test Cases" with option "Display Team Members". This list would help to generate the test packages. The selection of the test cases for the test package has do be done manually because there seems to be no filter for team members.
    Regards,
    Martin

  • How to Extract Test Cases from TFS 2013 to Excel

    How to extract test cases from 2013 Team Foundation Server to excel.
    Yuvaraj G

    Hi Yuvaraj,
    To export test cases in TFS 2013 to an Excel file, you can follow the steps as below:
    Create a query for the test cases that you want to export in Team Explorer
    Open an empty Excel file, click the tab of "Team"
    Click "New List" and then select the TFS server and the detailed team project
    In query list, select the query you created before, then click OK to export the test cases
    Best regards,
    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.

  • How to store test cases in multiple languages?

    We need to provide test cases in German an English and I would like to avoid having two projects.
    My idea is to use a template project which allows the translation of the process tree, and then have both test cases in one document (maybe using a word makro to jump to the needed language if that works).
    Do you know a better way to manage test cases in different languages?

    We need to provide test cases in German an English and I would like to avoid having two projects.
    My idea is to use a template project which allows the translation of the process tree, and then have both test cases in one document (maybe using a word makro to jump to the needed language if that works).
    Do you know a better way to manage test cases in different languages?

  • Creating a chart in TFS showing test cases that pass and failed using lightweight chart in Team Web Access

    How to you build a chart in TFS that show test cases results.
    I'm using lightweight charts in Team Web Access.
    In Team Web Access I go into my project, then I create test cases under the TEST tab and then run my test manually.  Now I want to create a testing progress result chart.  I go into the TEST tab, then click on test plan and notice that
    there is no Chart tab.
    Is this tab configurable or am I missing something?

    To my knowledge, charts are only available for work item queries in TFS web access. If you want to generate test result charts, you can do that using the TFS reporting data in the data warehouse (if your administrator configured it when setting up TFS).
    "You will find a fortune, though it will not be the one you seek." -
    Blind Seer, O Brother Where Art Thou
    Please Mark posts as answers or helpful so that others may find the fortune they seek.

  • How can i rename a jar file using only java code

    i have tried everything i can think of to accomplish this but nothing works.

    ghostbust555 wrote:
    In case you geniuses haven't realized I said I tried everything I can think of not that I tried everything. So help or shut up I realize that I didn't try everything but if you can't figure it out either DO NOT POST.
    And the question is how can i rename a jar file using java code? As it says in the title. Read.I would tell you to use the File.renameTo method, but surely that would have been obvious, and you would have tried it already? But maybe you didn't. You were kind of lacking in details in what you tried.
    And yes, I am a genius. Just don't confuse "genius" with "mind-reader".

  • How do I store images in a jar file to be displayed on a jsp?

    Afternoon all,
    I have created a java component which accepts some parameters and returns a string. The returned string contains html tags to display a table in a webpage when rendered through a browser.
    I want to be able to add this component to any java web project to display my table. The problem is that I want to use images in my table to give the appearance of curved corners.
    How do I store images in my component and render to a webpage?
    Thanks in advance,
    Alex

    You won't be able to make the install of this library as simple as the installation of a jar file. You can't access the images directly in the jar.
    There are a few approaches you can take:
    1 - jar file + resources:
    Have the install as being a jar and a "resources" directory which you store all the images in. Thus the images become part of the web application/web site and are accessible. Probably need to allow an entry in web.xml to configure where/what this directory is called.
    2 - jar file only:
    Provide a servlet to access the images, which will load them from the jar file, using the ClassLoader.getResourceAsStream(). Requires declaration of a servlet in the web.xml file. Won't be as efficient as having the images on disk, but will keep them bundled in the jar file.
    you would generate code such as <img src="myImgServlet?img=.....">
    Cheers,
    evnafets

  • How to extract the contents of the Jar file?

    Hello,
    Can anyone tell me how to extract the contents of the Jar file?
    An example will be highly appreciated.
    Thanks.

    From command line, or from within a java application?
    Kaj
    Btw. Why do you need to do it. You do know that you can add jars to the classpath and read resources from them without extracting the file?

  • How to combine the classes from 2 jar files into 1?

    Hi there
    I have got 2 jar files with the same name but the classes that they contain are different. So, I want to combine those 2 files into 1. Could anyone please tell me how to add the classes in a jar file to another jar file?
    Thanks for your help!
    From
    Edmund

    The jar utility allows you to extract files as well as put them into a jar. This is in the java docs.
    You might have to hand modify the manifest file if it was hand modified in the first place. All you should have to do is copy the text from one file to another. The manifest will have the same name so you will have to extract to different dirs so it isn't overwritten.
    Steps:
    -Create dir1 and dir2
    -Extract jar1 into dir1, Extract jar2 into dir2.
    -Manually examine manifests and combine if needed.
    -Copy files from one dir to another.
    -Use jar tool to create new jar.

Maybe you are looking for

  • How do I load data from R/3 into /BI0/TCUST_SALES

    Hi, There is a SAP supplied characteristic called 0CUST_SALES which has a text table called /BI0/TCUST_SALES. How do go about populating this table from the R/3 system? My version is BW 3.5 Thanks Ram

  • F1 button

    hello everybody! i've a problem with F1 event. When i'm on the ABAP-code and i press F1 button on a key world, the help is displayed. then when i press any link on the page displayed i cannot reach the page that should be linked. i have upgraded the

  • ClassCastException in oracle.sql.BLOB.createTemporary

    Hi, I'm having a ClassCastException problem using the method oracle.sql.BLOB.createTemporary while trying to store a BLOB value (JDBC classes12.jar). The problem is quite clear - if I use the method with a dedicated database connection that specifies

  • Can a payslip be dowloaded in HTML format?

    Hi guys,     my client wants a payslip to be dowloaded in html and sent to the user's through  the outlook. Plz suggest me whether a payslip can be downloaded in html format. the payslips are comings from a report as a output based on selection scree

  • Forms Timeout - Screen turn to blank if leave it idle for 5 min

    Dear gurus, I have a problem when ever i connect our oracle form through our OAS 10g, if the forms leave it idle after login more than 5 min and try to access again, the form will turn to blank screen and i have to force end task to re-connect again.