Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Including junit user defined tests.

LegacyForum Posts: 1,664 ✭✭
edited December 2016 in Jtest
How to include my junit tests with Jtest
My question is how do I import unit test cases that already exist and are defined with Junit into my Jtest?


  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    If your tests are located in the same folders as the classes they are testing, they are already imported. If they are elsewhere (somewhere other than the projects' location) you would need to make 2 projects. The first is for the classes we're interested in testing. The second is for the pre existing test classes. When the two projects are ready, you tell Jtest how to find test cases written by the user so that it may include those tests along with its normal procedure.

    In fact, Jtest has such a facililty built in. Depending on where they exist, you'll define information to Jtest so it can find them when it does the test case execution.

    Most development environments define their test locations in one of two ways.

    Either as a child of the project or as a seperate directory. For example:



    Other directory:


    You'll set this information in the test configuration option for test execution. It's under the Execution tab under the Search tab. This tells Jtest where it should search for tests. It has default settings for it's own generated tests and also one for pre existing tests that reside in the same source folders as the classes they were written to test.

    We recommend you leave the .jtest project as totally automatic and don't manually edit those files or add your own tests in there. It's easiest to just tell Jtest the location of the pre-existing test classes.

    Just fill the four fields with the correct locations and now Jtest will locate your tests and include them with the execution of automatically generated tests.

    If you have more questions, reply to this post.
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Is there any documentation that explains this more thoroughly? Perhaps with some step-by-step instructions for how to incorporate existing junit tests with Jtest?
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    There are a couple ways you can import your junit classes into Jtest. You can create a new project pointing to the directory containing the junits (File > New > Project > Jtest > Create Project Specifying Source Folders), or you can import the junits into an existing project. To do it the second way, right-click on a package and go to Import > General > File System, then browse to the directory with your junits.

    You will probably also need to modify your configurations so that Jtest knows where to find and execute your test classes. Go to Jtest configurations > Execution > Search, and add the pattern(s) to the second list ("Test classes that match...").

    There is some documentation in the Help Contents: go to Jtest User's Guide > Tasks > Customizing tests and settings > Unit testing > Extending the test suite > Integrating JUnit test classes created outside of Jtest.