1

I need to run my Selenium scripts in Jmeter. I would like to use Junit request. To reach this I need to make a .jar file from my test file. But I dont know how. This is my class with the test: enter image description here

When I try to make a .jar using: File -> Project Structure -> Artifacts -> + -> Jar from modules with dependencies -> here I am trying to choose class: enter image description here but it is not possible because my Login class is "Unit test class".

Is it possible to make .jar file from Unit test class somehow? And will the depedendecies in my pom.xml be preserved?

enter image description here

I tried to make it under Main class, but there is a problem with a JUnit annotations. enter image description here

I wasnt able to achieve this with these tips unfortunatelly :( https://maven.apache.org/plugins/maven-jar-plugin/examples/create-test-jar.html

user190245
  • 1,027
  • 1
  • 15
  • 31
akcenurt
  • 13
  • 3
  • if you use the easy way in the link provided, your test jar will be automatically generated when you execute maven build (mvn install). you don't have to explicitly generate jar – Harish Barma Feb 07 '23 at 14:32

1 Answers1

0
  1. You don't need to choose a main class because you're not creating an executable jar, you're creating a .jar with tests

  2. You need to tick "include tests" box

    enter image description here

I believe it would be easier to go for Maven Jar Plugin (from your own link) in combination with Maven Assembly Plugin to add all transitive dependencies.


And the easiest would be just switching to WebDriver Sampler which can be installed using JMeter Plugins Manager and put your code there, it will be much easier to debug and amend it, moreover you won't have to take care about running it with > 1 threads

Dmitri T
  • 159,985
  • 5
  • 83
  • 133