Submit and vote on feature ideas.

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.

Trying to access a Selenic Junit test from SOATest

Speedy993
Speedy993 Posts: 52

I posed this question before and while I apparently got it to work, I have since lost all of the source code for the Junit test and SOATest. So, my apologies.
Anyway, I have a simple Junit test of a web app. This test will search on a entered identifier number and then display some information that was found. This runs very well in Eclipse (4.24) with Selenic (2021.1.2.202206102308).

I had exported it a few times and on one of my attempts to run it from SOATest, I got an message that it had to use a version java 1.8 or lower.

So then I exported it as a java jar file including most of the options.

Then in SOATest (10.5.2.202112162000) I used the JUnit Executor and configured it thusly.

Unfortunately, I am getting an error complaining that there is not a runnable method. From what I have found when searching on this error message, it was mentioned that for JUnit, the test code must have @Test before the executable method, which my code does.
Error Message:
initializationError(com.Hennepin.DocShop): java.lang.Exception: No runnable methods
Additional Details:
java.lang.Exception: No runnable methods
at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:191)
at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:128)
at org.junit.runners.ParentRunner.validate(ParentRunner.java:416)
at org.junit.runners.ParentRunner.(ParentRunner.java:84)
at org.junit.runners.BlockJUnit4ClassRunner.(BlockJUnit4ClassRunner.java:65)
at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:10)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:36)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at com.parasoft.soavirt.tool.junitrunnertool.shaded.util.junit.JUnitRunner.run(JUnitRunner.java:34)
at com.parasoft.soavirt.tool.junitrunnertool.JUnitRunnerTool.execute(JUnitRunnerTool.java:29)
at webtool.extension.tool.CustomTool$ApplyTool.call(CustomTool.java:269)
at webtool.extension.tool.CustomTool$ApplyTool.call(CustomTool.java:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

Does anyone have any ideas what I messed up this time?

Sorry about blurring a lot of the text in the images. I am trying to keep it secure while showing as much as I can. Please let me know if any more details are needed.

Thanks!

Tagged:

Best Answer

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭
    edited October 2022 Answer ✓

    This is trying to run the jar file of my Selenic test I exported from Eclipse.

    This is OK. I'm just saying to consider importing the source project instead in case you find that easier. It can be less error prone because of the "Add Java Project" button which makes it really easy to add not only the project's class folder but all its dependencies.

    You can also do it this other way you say. This just puts more responsibility on you to make sure your jar is up to date and doesn't need to be rebuilt and that you really have all the other jars this one depends on.

    When you say to import the source files directly into the SOATest workspace, are you referring to the java files from the Eclipse Selenic project or some other source

    The java project is the folder that contains the .project file which contains the source folders (typically src/test/java) and build output directory (typically target/test-classes).

    You already have some other workspace where you had setup this project, right? All I'm saying is that you can import the exact same project into your SOAtest workspace as well, the one that has your .tst files.

    Is there an example documentation showing this type of project in SOATest? I have not been able to find anything searching Parasoft's websites.

    Parasoft SOAtest is a plugin for the Eclipse IDE. The tooling that lets you create and import Java projects is provided by the Java (JDT) plugin for the Eclipse IDE. There is general Eclipse documentation for working with Java projects in Eclipse:
    http://help.eclipse.org/latest/index.jsp?topic=/org.eclipse.jdt.doc.user/concepts/concept-java-project.htm

Answers

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭

    The JUnit Executor tool only supports JUnit 4 or JUnit 3. Your Selenium test looks like it was written for JUnit 5.

  • Speedy993
    Speedy993 Posts: 52

    Thanks benkin!
    I am trying to change the test in Eclipse to run with JUnit 4 but seem to be running into other issues now. I changed the includes from:
    import org.junit.jupiter.api.AfterEach;
    import org.junit.jupiter.api.BeforeEach;
    import org.junit.jupiter.api.Test;

    to:
    import org.junit.After;
    import org.junit.Before;
    import org.junit.Test;

    and changed the jar files in the class path from various junit-****-****-5.8.2 to junit-4.0
    but now am getting this error:
    java.lang.AbstractMethodError: Receiver class org.junit.runner.Description does not define or inherit an implementation of the resolved method 'abstract java.lang.Class getTestClass()' of interface com.parasoft.selenic.javaagent.junit.IDescription.
    Am I missing some other jar files or imports? I feel like I may still have a mix of different versions of junit or java.
    Thanks!

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭
    edited October 2022

    If you are running a JUnit 4 Selenium test then I don't know why you would be seeing errors about "com.parasoft.selenic.javaagent.junit.IDescription" which is a type that is internal to the Selenic Agent. Are you somehow trying to run SOAtest with the Selenic Java Agent?

    What I normally do is import the source project directly into my SOAtest workspace from File > Import > General > Existing Projects into Workspace. Then you can easily add the project's build output directory (target/classes) and all its classpath entries (JUnit and Selenium jars) from Parasoft > Preferences > System Properties > Add Java Project. Having the source project is convenient because this enables you to make changes and automatically recompile the test class. Otherwise, you can try re-building and exporting your test classes as a jar and manually add the dependent JUnit and Selenium jars.

  • Speedy993
    Speedy993 Posts: 52
    edited October 2022

    Perhaps I am doing this wrong. I created a number of Selenic tests in Eclipse as well as a number of tests in SOATest for a web application. What I want to do now is to run the Selenic tests (existing Selenic tests or new ones). I created a new SOATest test and set it up to use the JUnit Executor. This is trying to run the jar file of my Selenic test I exported from Eclipse. That is what I described above. I may have misunderstood how the Junit Executor is supposed to work.
    When you say to import the source files directly into the SOATest workspace, are you referring to the java files from the Eclipse Selenic project or some other source? I may have done this incorrectly as a new folder was created but no test components were created. Is there an example documentation showing this type of project in SOATest? I have not been able to find anything searching Parasoft's websites.
    Thanks!