You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by lbackstrom <lb...@avaya.com> on 2008/08/27 16:20:33 UTC

Using Junit capabilities of jmeter

I'm trying to use the JUnit capabilities of Jmeter to run performance testing
on an application.  I create a JUnit application and extend TestCase as
indicated.  I have a "suite" method that adds the real test methods to the
TestSuite.  I jar 2 classes up and put the jar file in the indicated
directory.  

When I run JMeter it seems to run fine, but it only seems to run the suite
method which is only adding the test case to a TestSuite and it doesn't
seems to actually run the tests contained in the test suite.  I suspect this
because in the actual test class, I can put in 10 second sleeps and the test
still completes in a millisecond or less. Here's my code sample - thanks for
any help you can offer:

public class PerformanceTest extends TestCase {
	
	public static void main(String[] args){
	      junit.textui.TestRunner.run(suite());
	}
	public static Test suite() {	
		TestSuite suite = new TestSuite("Performance Test for logging client...");		
		suite.addTest(new JUnit4TestAdapter(PerformanceTest2.class));		
		
		return suite;
	}
}

public class PerformanceTest2 {

	@Before
	public void setUp() throws Exception {
	}
	
	@Test
	public void assertTest()
	{
		boolean junk = true;
		assertTrue(junk);
	}

}
-- 
View this message in context: http://www.nabble.com/Using-Junit-capabilities-of-jmeter-tp19182027p19182027.html
Sent from the JMeter - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Using Junit capabilities of jmeter

Posted by sebb <se...@gmail.com>.
Try using the example in the manual:

http://jakarta.apache.org/jmeter/usermanual/component_reference.html#JUnit_Request

On 28/08/2008, lbackstrom <lb...@avaya.com> wrote:
>
>  Thanks for the reply.  I still can't get it to actually run the test that we
>  want to run.  It seems to run the suite() method, but ignores the runTest()
>  method to run it.  Here's my code now:
>
>  public static Test suite() {
>                     TestSuite suite = new TestSuite();
>
>                     try
>                           {
>                                   System.out.println("Sleeping");
>                                   Thread.sleep(5000);
>                           }
>                           catch (Exception e){}
>
>                     suite.addTest(new PerformanceTest("PerformanceTest for logging client
>  ...") {
>                         public void runTest() {
>                             testHelloWorld();
>
>
>                         }
>
>                     });
>
>                     return suite;
>
>           }
>
>           public void testHelloWorld()
>           {
>                   try
>                   {
>                           System.out.println("Sleeping");
>                           Thread.sleep(5000);
>                   }
>                   catch (Exception e){}
>                   boolean junk = false;
>                   assertTrue(junk);
>                   System.out.println("Hello World");
>           }
>
>  We put sleeps and println's in there to see if we could see what is
>  happening.  The first print of "Sleeping" is output to the Jmeter results
>  screen, and the sleep occurs, but the one in the "testHelloWorld" method is
>  never seen.
>
>  Thanks again.
>
>
>
>
>  sebb-2-2 wrote:
>  >
>  > On 27/08/2008, lbackstrom <lb...@avaya.com> wrote:
>  >>
>  >>  I'm trying to use the JUnit capabilities of Jmeter to run performance
>  >> testing
>  >>  on an application.  I create a JUnit application and extend TestCase as
>  >>  indicated.  I have a "suite" method that adds the real test methods to
>  >> the
>  >>  TestSuite.  I jar 2 classes up and put the jar file in the indicated
>  >>  directory.
>  >>
>  >>  When I run JMeter it seems to run fine, but it only seems to run the
>  >> suite
>  >>  method which is only adding the test case to a TestSuite and it doesn't
>  >>  seems to actually run the tests contained in the test suite.  I suspect
>  >> this
>  >>  because in the actual test class, I can put in 10 second sleeps and the
>  >> test
>  >>  still completes in a millisecond or less. Here's my code sample - thanks
>  >> for
>  >>  any help you can offer:
>  >>
>  >>  public class PerformanceTest extends TestCase {
>  >>
>  >>         public static void main(String[] args){
>  >>               junit.textui.TestRunner.run(suite());
>  >>         }
>  >>         public static Test suite() {
>  >>                 TestSuite suite = new TestSuite("Performance Test for
>  >> logging client...");
>  >>                 suite.addTest(new
>  >> JUnit4TestAdapter(PerformanceTest2.class));
>  >>
>  >>                 return suite;
>  >>         }
>  >>  }
>  >>
>  >>  public class PerformanceTest2 {
>  >>
>  >>         @Before
>  >>         public void setUp() throws Exception {
>  >>         }
>  >>
>  >>         @Test
>  >
>  > JMeter does not support JUnit 4.x which uses annotations.
>  >
>  > Annotations require Java 1.5+; JMeter currently supports 1.4+
>  >
>  >>         public void assertTest()
>  >>         {
>  >>                 boolean junk = true;
>  >>                 assertTrue(junk);
>  >>         }
>  >>
>  >>  }
>  >>
>  >> --
>  >>  View this message in context:
>  >> http://www.nabble.com/Using-Junit-capabilities-of-jmeter-tp19182027p19182027.html
>  >>  Sent from the JMeter - User mailing list archive at Nabble.com.
>  >>
>  >>
>  >>  ---------------------------------------------------------------------
>  >>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  >>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>  >>
>  >>
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>  >
>  >
>  >
>
>
> --
>  View this message in context: http://www.nabble.com/Using-Junit-capabilities-of-jmeter-tp19182027p19209191.html
>
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Using Junit capabilities of jmeter

Posted by lbackstrom <lb...@avaya.com>.
Thanks for the reply.  I still can't get it to actually run the test that we
want to run.  It seems to run the suite() method, but ignores the runTest()
method to run it.  Here's my code now:

public static Test suite() {
		    TestSuite suite = new TestSuite();
		    
		    try
			  {
				  System.out.println("Sleeping");
				  Thread.sleep(5000);
			  }
			  catch (Exception e){}
		    
		    suite.addTest(new PerformanceTest("PerformanceTest for logging client
...") {
		        public void runTest() {
		            testHelloWorld();
		            
		            
		        }
		        
		    });

		    return suite;
	  
	  }
	  
	  public void testHelloWorld()
	  {
		  try
		  {
			  System.out.println("Sleeping");
			  Thread.sleep(5000);
		  }
		  catch (Exception e){}
		  boolean junk = false;
		  assertTrue(junk);
		  System.out.println("Hello World");
	  }

We put sleeps and println's in there to see if we could see what is
happening.  The first print of "Sleeping" is output to the Jmeter results
screen, and the sleep occurs, but the one in the "testHelloWorld" method is
never seen.

Thanks again.



sebb-2-2 wrote:
> 
> On 27/08/2008, lbackstrom <lb...@avaya.com> wrote:
>>
>>  I'm trying to use the JUnit capabilities of Jmeter to run performance
>> testing
>>  on an application.  I create a JUnit application and extend TestCase as
>>  indicated.  I have a "suite" method that adds the real test methods to
>> the
>>  TestSuite.  I jar 2 classes up and put the jar file in the indicated
>>  directory.
>>
>>  When I run JMeter it seems to run fine, but it only seems to run the
>> suite
>>  method which is only adding the test case to a TestSuite and it doesn't
>>  seems to actually run the tests contained in the test suite.  I suspect
>> this
>>  because in the actual test class, I can put in 10 second sleeps and the
>> test
>>  still completes in a millisecond or less. Here's my code sample - thanks
>> for
>>  any help you can offer:
>>
>>  public class PerformanceTest extends TestCase {
>>
>>         public static void main(String[] args){
>>               junit.textui.TestRunner.run(suite());
>>         }
>>         public static Test suite() {
>>                 TestSuite suite = new TestSuite("Performance Test for
>> logging client...");
>>                 suite.addTest(new
>> JUnit4TestAdapter(PerformanceTest2.class));
>>
>>                 return suite;
>>         }
>>  }
>>
>>  public class PerformanceTest2 {
>>
>>         @Before
>>         public void setUp() throws Exception {
>>         }
>>
>>         @Test
> 
> JMeter does not support JUnit 4.x which uses annotations.
> 
> Annotations require Java 1.5+; JMeter currently supports 1.4+
> 
>>         public void assertTest()
>>         {
>>                 boolean junk = true;
>>                 assertTrue(junk);
>>         }
>>
>>  }
>>
>> --
>>  View this message in context:
>> http://www.nabble.com/Using-Junit-capabilities-of-jmeter-tp19182027p19182027.html
>>  Sent from the JMeter - User mailing list archive at Nabble.com.
>>
>>
>>  ---------------------------------------------------------------------
>>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Using-Junit-capabilities-of-jmeter-tp19182027p19209191.html
Sent from the JMeter - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Using Junit capabilities of jmeter

Posted by sebb <se...@gmail.com>.
On 27/08/2008, lbackstrom <lb...@avaya.com> wrote:
>
>  I'm trying to use the JUnit capabilities of Jmeter to run performance testing
>  on an application.  I create a JUnit application and extend TestCase as
>  indicated.  I have a "suite" method that adds the real test methods to the
>  TestSuite.  I jar 2 classes up and put the jar file in the indicated
>  directory.
>
>  When I run JMeter it seems to run fine, but it only seems to run the suite
>  method which is only adding the test case to a TestSuite and it doesn't
>  seems to actually run the tests contained in the test suite.  I suspect this
>  because in the actual test class, I can put in 10 second sleeps and the test
>  still completes in a millisecond or less. Here's my code sample - thanks for
>  any help you can offer:
>
>  public class PerformanceTest extends TestCase {
>
>         public static void main(String[] args){
>               junit.textui.TestRunner.run(suite());
>         }
>         public static Test suite() {
>                 TestSuite suite = new TestSuite("Performance Test for logging client...");
>                 suite.addTest(new JUnit4TestAdapter(PerformanceTest2.class));
>
>                 return suite;
>         }
>  }
>
>  public class PerformanceTest2 {
>
>         @Before
>         public void setUp() throws Exception {
>         }
>
>         @Test

JMeter does not support JUnit 4.x which uses annotations.

Annotations require Java 1.5+; JMeter currently supports 1.4+

>         public void assertTest()
>         {
>                 boolean junk = true;
>                 assertTrue(junk);
>         }
>
>  }
>
> --
>  View this message in context: http://www.nabble.com/Using-Junit-capabilities-of-jmeter-tp19182027p19182027.html
>  Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org