You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by "nagkumar (via GitHub)" <gi...@apache.org> on 2023/06/02 07:16:51 UTC

[GitHub] [jmeter] nagkumar opened a new issue, #5957: JUnit 5 Sampler to discover JUnit 5 Test Cases

nagkumar opened a new issue, #5957:
URL: https://github.com/apache/jmeter/issues/5957

   ### Use case
   
   ![image](https://github.com/apache/jmeter/assets/332234/b6c0b2a5-df50-45cf-9253-3360173a808a)
   
   
   Existing JUNIT Sampler has no option to discover JUnit 5 Suites or Classes.. can you pl. include the same..
   
   ### Possible solution
   
   _No response_
   
   ### Possible workarounds
   
   _No response_
   
   ### JMeter Version
   
   latest
   
   ### Java Version
   
   latest
   
   ### OS Version
   
   windows 11


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [jmeter] vlsi commented on issue #5957: JUnit Sampler to support JUnit 5 Test Cases or JUnit 5 @Suite test cases

Posted by "vlsi (via GitHub)" <gi...@apache.org>.
vlsi commented on issue #5957:
URL: https://github.com/apache/jmeter/issues/5957#issuecomment-1583997043

   I would suggest setting a breakpoint into the sampler class and checking if JUnit receives a proper class name, and then checking what is JUnit doing.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [jmeter] nagkumar commented on issue #5957: JUnit Sampler to support JUnit 5 Test Cases or JUnit 5 @Suite test cases

Posted by "nagkumar (via GitHub)" <gi...@apache.org>.
nagkumar commented on issue #5957:
URL: https://github.com/apache/jmeter/issues/5957#issuecomment-1577434428

   Thank you for the details.
   
   Should JUnit5Sample extend `AbstractJavaSamplerClient `or like `JUnitSample `should it extend `AbstractSampler`
   
   If it should `AbstractJavaSamplerClient `, then can I follow `org.apache.jmeter.protocol.java.test.JavaTest` or `org.apache.jmeter.protocol.java.test.SleepTest`, what is the significance of these Samples..
   
   Also, not very clear, why the samper should worry of setup and teardown or Suite etc as it must be the duty of the launcher to handle.. at least in JUnit5.
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [jmeter] nagkumar commented on issue #5957: JUnit Sampler to support JUnit 5 Test Cases or JUnit 5 @Suite test cases

Posted by "nagkumar (via GitHub)" <gi...@apache.org>.
nagkumar commented on issue #5957:
URL: https://github.com/apache/jmeter/issues/5957#issuecomment-1583953955

   Any support on this please..


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [jmeter] nagkumar commented on issue #5957: JUnit 5 Sampler to discover JUnit 5 Test Cases

Posted by "nagkumar (via GitHub)" <gi...@apache.org>.
nagkumar commented on issue #5957:
URL: https://github.com/apache/jmeter/issues/5957#issuecomment-1573319281

   I force changed the .jmx file to JUnit 5 class, which fails like this..
   ```
   
   java.lang.ClassCastException: class com.tejasoft.tests.ju.ju5.ut.perf.TestAllPerfSuite cannot be cast to class junit.framework.TestCase (com.tejasoft.tests.ju.ju5.ut.perf.TestAllPerfSuite and junit.framework.TestCase are in unnamed module of loader org.apache.jmeter.DynamicClassLoader @72ea2f77)
   	at org.apache.jmeter.protocol.java.sampler.JUnitSampler.initializeTestObject(JUnitSampler.java:675) ~[ApacheJMeter_junit-5.4.1.jar:5.4.1]
   	at org.apache.jmeter.protocol.java.sampler.JUnitSampler.threadStarted(JUnitSampler.java:647) ~[ApacheJMeter_junit-5.4.1.jar:5.4.1]
   	at org.apache.jmeter.threads.JMeterThread$ThreadListenerTraverser.addNode(JMeterThread.java:784) [ApacheJMeter_core-5.4.1.jar:5.4.1]
   	at org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:993) [jorphan-5.4.1.jar:5.4.1]
   	at org.apache.jorphan.collections.HashTree.traverse(HashTree.java:976) [jorphan-5.4.1.jar:5.4.1]
   	at org.apache.jmeter.threads.JMeterThread.threadStarted(JMeterThread.java:752) [ApacheJMeter_core-5.4.1.jar:5.4.1]
   	at org.apache.jmeter.threads.JMeterThread.initRun(JMeterThread.java:740) [ApacheJMeter_core-5.4.1.jar:5.4.1]
   	at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:252) [ApacheJMeter_core-5.4.1.jar:5.4.1]
   	at java.lang.Thread.run(Thread.java:1589) [?:?]
   ```
   
   Are there any support for additional JUnit 5-specific samplers...if yes, kindly inform
   
   ```
   <?xml version="1.0" encoding="UTF-8"?>
   <jmeterTestPlan version="1.2" properties="5.0" jmeter="5.4.1">
     <hashTree>
       <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
         <stringProp name="TestPlan.comments"></stringProp>
         <boolProp name="TestPlan.functional_mode">false</boolProp>
         <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
         <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
           <collectionProp name="Arguments.arguments"/>
         </elementProp>
         <stringProp name="TestPlan.user_define_classpath"></stringProp>
       </TestPlan>
       <hashTree>
         <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="JUnit Test Thread Group" enabled="true">
           <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
           <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" enabled="true">
             <boolProp name="LoopController.continue_forever">false</boolProp>
             <stringProp name="LoopController.loops">2</stringProp>
           </elementProp>
           <stringProp name="ThreadGroup.num_threads">10</stringProp>
           <stringProp name="ThreadGroup.ramp_time">5</stringProp>
           <longProp name="ThreadGroup.start_time">1678980642000</longProp>
           <longProp name="ThreadGroup.end_time">1678980642000</longProp>
           <boolProp name="ThreadGroup.scheduler">false</boolProp>
           <stringProp name="ThreadGroup.duration"></stringProp>
           <stringProp name="ThreadGroup.delay"></stringProp>
         </ThreadGroup>
         <hashTree>
           <JUnitSampler guiclass="JUnitTestSamplerGui" testclass="JUnitSampler" testname="JUnit 5 Sampler" enabled="true">
             <stringProp name="junitSampler.classname">com.tejasoft.tests.ju.ju3.ut.learn.TestJU3</stringProp>
   <!--           <stringProp name="junitSampler.classname">com.tejasoft.tests.ju.ju5.ut.perf.TestAllPerfSuite</stringProp> -->
             <boolProp name="junitSampler.appendError">false</boolProp>
             <boolProp name="junitSampler.appendException">false</boolProp>
           </JUnitSampler>
           <hashTree/>
         </hashTree>
       </hashTree>
     </hashTree>
   </jmeterTestPlan>
   
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [jmeter] nagkumar commented on issue #5957: JUnit Sampler to support JUnit 5 Test Cases or JUnit 5 @Suite test cases

Posted by "nagkumar (via GitHub)" <gi...@apache.org>.
nagkumar commented on issue #5957:
URL: https://github.com/apache/jmeter/issues/5957#issuecomment-1579010544

   Another Observation is JUnitSampler is optionally measuring only test method time and not setup and teardown methods, that is a misleading info, as these two are part of test execution.
   
   Also another bug is there could be many setup and teardown methods both in JUnit 4 and JUnit 5..
   
   [https://medium.com/javarevisited/execution-order-of-junit-annotations-cda673cda470](https://medium.com/javarevisited/execution-order-of-junit-annotations-cda673cda470)
   
   ![image](https://github.com/apache/jmeter/assets/332234/61246045-4d7f-49ef-8758-226a2c1cad79)
   
   However, JUnitSampler just handle only one method of setup and teardown.. 
   
   Also JUnitSampler expects both default constructor and constructor with string name.. while real testcase fails to execute such 2 constructor test case.. not sure if any have use JUnitSampler at all..
   
   Keeping it similar could be just take the JUnit 5 Suite Class and JUnit Test Class (optionally with test method or test methods) and execute them through JUnit 5 Lanucher..
   
   That way even UI would be simple and easy to understand, once JUnit 5 is accepted, I am sure we can find the same JUnit5Sampler to accept both JUnit 4 and JUnit 3 too.. as JUnit 5 has such support engines.
   
   Pl. share your thoughts to further clarify the scope
   
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [jmeter] nagkumar commented on issue #5957: JUnit Sampler to support JUnit 5 Test Cases or JUnit 5 @Suite test cases

Posted by "nagkumar (via GitHub)" <gi...@apache.org>.
nagkumar commented on issue #5957:
URL: https://github.com/apache/jmeter/issues/5957#issuecomment-1580313389

   ```
       private final SummaryGeneratingListener runSuiteClass()
       {
   	LauncherDiscoveryRequestBuilder requestBuilder = LauncherDiscoveryRequestBuilder.request();
   	requestBuilder.selectors(selectClass(getJUnit5TestClass()));
   
   	Launcher launcher = LauncherFactory.create();
   	SummaryGeneratingListener listener = new SummaryGeneratingListener();
   	launcher.registerTestExecutionListeners(listener);
   	launcher.execute(requestBuilder.build());
   	listener.getSummary().printTo(new PrintWriter(System.out));
   	return listener;
       }
   ```
   
   This is the code to run JUnit 5 Suite class, this is able to run the test suite properly when run from the individual main class.. however when I run it as part of JUnit5Sampler with code block
   
    ```
   public SampleResult sample(final Entry aEntry)
       {
   	final SampleResult lSampleResult = new SampleResult();
   	lSampleResult.sampleStart();
   
   	try
   	{
   	    final TestExecutionSummary lSummary = runSuiteClass().getSummary();
   
   	    if (lSummary.getTestsFailedCount() == 0)
   	    {
   		lSampleResult.setSuccessful(true);
   	    }
   	    else
   	    {
   		setFailedResponse(lSampleResult, "Some tests failed.");
   	    }
   	}
   	catch (final Exception aException)
   	{
   	    setFailedResponse(lSampleResult, "Exception occurred: " + aException.getMessage());
   	}
   
   	lSampleResult.sampleEnd();
   	return lSampleResult;
       }
   
   
   ```
   
   JMeter does not run the test case for sure as it returns immediately, however results are shown as 100% success...
   
   
   The .jmx file used is
   
   ```
   <jmeterTestPlan version="1.2" properties="5.0" jmeter="5.5">
       <hashTree>
   	<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
   	    <stringProp name="TestPlan.comments"/>
   	    <boolProp name="TestPlan.functional_mode">false</boolProp>
   	    <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
   	    <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables"
   			 enabled="true">
   		<collectionProp name="Arguments.arguments"/>
   	    </elementProp>
   	    <stringProp name="TestPlan.user_define_classpath"/>
   	</TestPlan>
   	<hashTree>
   	    <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="JUnit Test Thread Group" enabled="true">
   		<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
   		<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" enabled="true">
   		    <boolProp name="LoopController.continue_forever">false</boolProp>
   		    <stringProp name="LoopController.loops">2</stringProp>
   		</elementProp>
   		<stringProp name="ThreadGroup.num_threads">10</stringProp>
   		<stringProp name="ThreadGroup.ramp_time">5</stringProp>
   		<longProp name="ThreadGroup.start_time">1678980642000</longProp>
   		<longProp name="ThreadGroup.end_time">1678980642000</longProp>
   		<boolProp name="ThreadGroup.scheduler">false</boolProp>
   		<stringProp name="ThreadGroup.duration"/>
   		<stringProp name="ThreadGroup.delay"/>
   	    </ThreadGroup>
   	    <hashTree>
   		<JUnit5Sampler guiclass="JUnitTestSamplerGui" testclass="JUnit5Sampler" testname="JUnit 5 Sampler" enabled="true">
   		    <stringProp name="junit5Sampler.classname">com.tejasoft.tests.ju.ju5.ut.perf.TestAllPerfSuite</stringProp>
   		    <boolProp name="junit5Sampler.appendError">false</boolProp>
   		    <boolProp name="junit5Sampler.appendException">false</boolProp>
   		</JUnit5Sampler>
   		<hashTree/>
   	    </hashTree>
   	</hashTree>
       </hashTree>
   </jmeterTestPlan>
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [jmeter] nagkumar commented on issue #5957: JUnit Sampler to support JUnit 5 Test Cases or JUnit 5 @Suite test cases

Posted by "nagkumar (via GitHub)" <gi...@apache.org>.
nagkumar commented on issue #5957:
URL: https://github.com/apache/jmeter/issues/5957#issuecomment-1578997121

      Further study of JUnitSampler, which of these properties are to be supported..
   
        ```
    private static final String CLASSNAME = "junitSampler.classname";
       private static final String CONSTRUCTORSTRING = "junitsampler.constructorstring";
       private static final String METHOD = "junitsampler.method";
       private static final String ERROR = "junitsampler.error";
       private static final String ERRORCODE = "junitsampler.error.code";
       private static final String FAILURE = "junitsampler.failure";
       private static final String FAILURECODE = "junitsampler.failure.code";
       private static final String SUCCESS = "junitsampler.success";
       private static final String SUCCESSCODE = "junitsampler.success.code";
       private static final String FILTER = "junitsampler.pkg.filter";
       private static final String DOSETUP = "junitsampler.exec.setup";
       private static final String APPEND_ERROR = "junitsampler.append.error";
       private static final String APPEND_EXCEPTION = "junitsampler.append.exception";
       private static final String JUNIT4 = "junitsampler.junit4";
       private static final String CREATE_INSTANCE_PER_SAMPLE="junitsampler.createinstancepersample";
   ```
   
   This configuration looks too complex as when doing a performance test, take the class and load it, asking for so much info, not sure if that can confuse a lot.. 
   
   As per my little understanding of JMeter except for the CLASSNAME AND method name others should not be asked, also if it is a suite even the method name is not needed..
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [jmeter] nagkumar commented on issue #5957: JUnit Sampler to support JUnit 5 Test Cases or JUnit 5 @Suite test cases

Posted by "nagkumar (via GitHub)" <gi...@apache.org>.
nagkumar commented on issue #5957:
URL: https://github.com/apache/jmeter/issues/5957#issuecomment-1577263543

   Sure, would attempt.. any briefing on how to go about would help.. meanwhile, I am understanding the JUnitSample existing codebase..


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [jmeter] nagkumar commented on issue #5957: JUnit Sampler to support JUnit 5 Test Cases or JUnit 5 @Suite test cases

Posted by "nagkumar (via GitHub)" <gi...@apache.org>.
nagkumar commented on issue #5957:
URL: https://github.com/apache/jmeter/issues/5957#issuecomment-1576796602

   Can any respond I am sure there must have some plugin out there that must have implemented junit 5 sampler already.. can you pl. point to the same..


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [jmeter] vlsi commented on issue #5957: JUnit Sampler to support JUnit 5 Test Cases or JUnit 5 @Suite test cases

Posted by "vlsi (via GitHub)" <gi...@apache.org>.
vlsi commented on issue #5957:
URL: https://github.com/apache/jmeter/issues/5957#issuecomment-1576821203

   There's no such plugin within JMeter core.
   Pull requests are welcome.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [jmeter] vlsi commented on issue #5957: JUnit Sampler to support JUnit 5 Test Cases or JUnit 5 @Suite test cases

Posted by "vlsi (via GitHub)" <gi...@apache.org>.
vlsi commented on issue #5957:
URL: https://github.com/apache/jmeter/issues/5957#issuecomment-1577441303

   I think AbstractSampler should be enough


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [jmeter] nagkumar commented on issue #5957: JUnit Sampler to support JUnit 5 Test Cases or JUnit 5 @Suite test cases

Posted by "nagkumar (via GitHub)" <gi...@apache.org>.
nagkumar commented on issue #5957:
URL: https://github.com/apache/jmeter/issues/5957#issuecomment-1584471893

   My suspotion is what is the purpose of 		<JUnit5Sampler guiclass="JUnitTestSamplerGui" testclass="JUnit5Sampler" testname="JUnit 5 Sampler" enabled="true">
   `JUnitTestSamplerGui`
   
   as in headless mode of running is this value used.. if there are any errors around this.. should we not see such errors in jmeter.log file.. 
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [jmeter] nagkumar commented on issue #5957: JUnit Sampler to support JUnit 5 Test Cases or JUnit 5 @Suite test cases

Posted by "nagkumar (via GitHub)" <gi...@apache.org>.
nagkumar commented on issue #5957:
URL: https://github.com/apache/jmeter/issues/5957#issuecomment-1584485237

   ```
   package com.tejasoft.tests.ju.ju5.ut.perf.jmeter.ext;
   
   import org.apache.jmeter.samplers.AbstractSampler;
   import org.apache.jmeter.samplers.Entry;
   import org.apache.jmeter.samplers.SampleResult;
   import org.junit.jupiter.api.TestInstance;
   import org.junit.platform.launcher.Launcher;
   import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder;
   import org.junit.platform.launcher.core.LauncherFactory;
   import org.junit.platform.launcher.listeners.SummaryGeneratingListener;
   import org.junit.platform.launcher.listeners.TestExecutionSummary;
   import org.slf4j.Logger;
   import org.slf4j.LoggerFactory;
   
   import java.io.PrintWriter;
   import java.io.Serial;
   import java.lang.annotation.Annotation;
   import java.lang.reflect.Method;
   
   import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass;
   
   @TestInstance(TestInstance.Lifecycle.PER_CLASS)
   public final class JUnit5Sampler extends AbstractSampler implements JUnit5SamplerAttributes
   {
       private static final Logger log = LoggerFactory.getLogger(JUnit5Sampler.class);
   
       @Serial
       private static final long serialVersionUID = 240L;
   
       private static final boolean CREATE_INSTANCE_PER_SAMPLE_DEFAULT = false;
   
       public JUnit5Sampler()
       {
   	super();
       }
   
       public final String getJUnit5TestClass()
       {
   	return getPropertyAsString(JUNIT5_TEST_CLASS);
       }
   
       public final void setJUnit5TestClass(final String aJUnit5TestClass)
       {
   	setProperty(JUNIT5_TEST_CLASS, aJUnit5TestClass);
       }
   
       public String getConstructorString()
       {
   	return getPropertyAsString(CONSTRUCTORSTRING);
       }
   
       public void setConstructorString(String constructorString)
       {
   	setProperty(CONSTRUCTORSTRING, constructorString);
       }
   
       public String getMethod()
       {
   	return getPropertyAsString(METHOD);
       }
   
       public void setMethod(String method)
       {
   	setProperty(METHOD, method);
       }
   
       public String getSuccess()
       {
   	return getPropertyAsString(SUCCESS);
       }
   
       public void setSuccess(String success)
       {
   	setProperty(SUCCESS, success);
       }
   
       public String getFailure()
       {
   	return getPropertyAsString(FAILURE);
       }
   
       public void setFailure(String failure)
       {
   	setProperty(FAILURE, failure);
       }
   
       public String getError()
       {
   	return getPropertyAsString(ERROR);
       }
   
       public void setError(String error)
       {
   	setProperty(ERROR, error);
       }
   
       public String getFilter()
       {
   	return getPropertyAsString(FILTER);
       }
   
       public void setFilter(String filter)
       {
   	setProperty(FILTER, filter);
       }
   
       public boolean getAppendError()
       {
   	return getPropertyAsBoolean(APPEND_ERROR);
       }
   
       public void setAppendError(boolean append)
       {
   	setProperty(APPEND_ERROR, append);
       }
   
       public boolean getAppendException()
       {
   	return getPropertyAsBoolean(APPEND_EXCEPTION);
       }
   
       public void setAppendException(boolean append)
       {
   	setProperty(APPEND_EXCEPTION, append);
       }
   
       public boolean getCreateInstancePerSample()
       {
   	return getPropertyAsBoolean(CREATE_INSTANCE_PER_SAMPLE, CREATE_INSTANCE_PER_SAMPLE_DEFAULT);
       }
   
       public void setCreateInstancePerSample(boolean createInstance)
       {
   	setProperty(CREATE_INSTANCE_PER_SAMPLE, createInstance);
       }
   
       public String toString()
       {
   	return getClass().getSimpleName() + " " + getName() + "(" + getJUnit5TestClass() + "." + getMethod() + ")";
       }
   
       public String getErrorCode()
       {
   	return getPropertyAsString(ERRORCODE);
       }
   
       public String getSuccessCode()
       {
   	return getPropertyAsString(SUCCESSCODE);
       }
   
       public String getFailureCode()
       {
   	return getPropertyAsString(FAILURECODE);
       }
   
       private Method getMethodWithAnnotation(Object testObject, Class<? extends Annotation> annotation)
       {
   	Class<?> clazz = testObject.getClass();
   	for (Method method : clazz.getMethods())
   	{
   	    if (method.isAnnotationPresent(annotation))
   	    {
   		return method;
   	    }
   	}
   	return null;
       }
   
       @Override
       public SampleResult sample(final Entry aEntry)
       {
   	final SampleResult lSampleResult = new SampleResult();
   	lSampleResult.sampleStart();
   
   	try
   	{
   	    final TestExecutionSummary lSummary = runSuiteClass().getSummary();
   
   	    if (lSummary.getTestsFailedCount() == 0)
   	    {
   		lSampleResult.setSuccessful(true);
   	    }
   	    else
   	    {
   		setFailedResponse(lSampleResult, "Some tests failed.");
   	    }
   	}
   	catch (final Exception aException)
   	{
   	    setFailedResponse(lSampleResult, "Exception occurred: " + aException.getMessage());
   	}
   
   	lSampleResult.sampleEnd();
   	return lSampleResult;
       }
   
       private final SummaryGeneratingListener runSuiteClass()
       {
   	LauncherDiscoveryRequestBuilder requestBuilder = LauncherDiscoveryRequestBuilder.request();
   	requestBuilder.selectors(selectClass(getJUnit5TestClass()));
   
   	Launcher launcher = LauncherFactory.create();
   	SummaryGeneratingListener listener = new SummaryGeneratingListener();
   	launcher.registerTestExecutionListeners(listener);
   	launcher.execute(requestBuilder.build());
   	listener.getSummary().printTo(new PrintWriter(System.out));
   	return listener;
       }
   
       private static final void setFailedResponse(final SampleResult aSampleResult, final String aFailMessage)
       {
   	aSampleResult.setSuccessful(false);
   	aSampleResult.setResponseMessage(aFailMessage);
   	aSampleResult.setResponseCode("500");
       }
   }
   
   ```
   
   and 
   
   ```
   package com.tejasoft.tests.ju.ju5.ut.perf.jmeter.ext;
   
   public interface JUnit5SamplerAttributes
   {
       String JUNIT_5_SAMPLER_PROP_PREFIX = "junit5Sampler.";
       String JUNIT5_TEST_CLASS = JUNIT_5_SAMPLER_PROP_PREFIX + "classname";
       String METHOD = JUNIT_5_SAMPLER_PROP_PREFIX + "method";
   
       String CONSTRUCTORSTRING = JUNIT_5_SAMPLER_PROP_PREFIX + "constructorstring";
       String ERROR = JUNIT_5_SAMPLER_PROP_PREFIX + "error";
       String ERRORCODE = JUNIT_5_SAMPLER_PROP_PREFIX + "error.code";
       String FAILURE = JUNIT_5_SAMPLER_PROP_PREFIX + "failure";
       String FAILURECODE = JUNIT_5_SAMPLER_PROP_PREFIX + "failure.code";
       String SUCCESS = JUNIT_5_SAMPLER_PROP_PREFIX + "success";
       String SUCCESSCODE = JUNIT_5_SAMPLER_PROP_PREFIX + "success.code";
       String FILTER = JUNIT_5_SAMPLER_PROP_PREFIX + "pkg.filter";
       String APPEND_ERROR = JUNIT_5_SAMPLER_PROP_PREFIX + "append.error";
       String APPEND_EXCEPTION = JUNIT_5_SAMPLER_PROP_PREFIX + "append.exception";
       String CREATE_INSTANCE_PER_SAMPLE = JUNIT_5_SAMPLER_PROP_PREFIX + "createinstancepersample";
   }
   
   ```
   
   this is the code.. I am using..


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [jmeter] nagkumar commented on issue #5957: JUnit Sampler to support JUnit 5 Test Cases or JUnit 5 @Suite test cases

Posted by "nagkumar (via GitHub)" <gi...@apache.org>.
nagkumar commented on issue #5957:
URL: https://github.com/apache/jmeter/issues/5957#issuecomment-1584468809

   > I would suggest setting a breakpoint into the sampler class and checking if JUnit receives a proper class name, and then checking what is JUnit doing.
   
   Yes all of the properties are properly coming in also reports says 100% success
   
   <img width="1246" alt="image" src="https://github.com/apache/jmeter/assets/332234/e879e749-645f-408c-8306-c0f720418e5e">
   
   However I am sure tests are not running a
   [jmeter.log](https://github.com/apache/jmeter/files/11706056/jmeter.log)
   s the tests should take 2 to 3 min and also I don't see a lot of log info that should come up while running the tests..


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [jmeter] vlsi commented on issue #5957: JUnit Sampler to support JUnit 5 Test Cases or JUnit 5 @Suite test cases

Posted by "vlsi (via GitHub)" <gi...@apache.org>.
vlsi commented on issue #5957:
URL: https://github.com/apache/jmeter/issues/5957#issuecomment-1577292041

   I would suggest to start with https://junit.org/junit5/docs/current/user-guide/#launcher-api
   
   JUnit5 provides API to discover, and run tests. At the same time it provides `JUnit Vintage` engine that can discover and execute JUnit 3 and JUnit 4 tests.
   
   I would suggest adding `src/protocols/junit5` module, add jupiter launcher API dependency there, and try to get it working.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org