You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by bu...@apache.org on 2009/09/23 02:59:07 UTC

DO NOT REPLY [Bug 47888] New: JUnit Sampler re-uses test object

https://issues.apache.org/bugzilla/show_bug.cgi?id=47888

           Summary: JUnit Sampler re-uses test object
           Product: JMeter
           Version: unspecified
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Main
        AssignedTo: jmeter-dev@jakarta.apache.org
        ReportedBy: sebb@apache.org


The JUnit sampler currently re-uses the same test object for each sample.

This is not how JUnit tests work, as the test runner creates a new instance of
the test class for each test.

Re-using the instance means that tests such as the following contrived example
will fail if a sampler is run more than once in a loop:

    private int i = 123;
    public void testRerun(){
        assertEquals(123,i);
        i++;
    }

The sampler needs to recreate the test instance for each sample.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 47888] JUnit Sampler re-uses test object

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47888

--- Comment #2 from Sebb <se...@apache.org> 2009-09-22 18:46:05 PDT ---
I see - good point.

It does mean that there are restrictions on the tests that can be run using
JMeter, but that's probably worth it - so it will be documented rather than
changed.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 47888] JUnit Sampler re-uses test object

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47888

--- Comment #3 from peter lin <wo...@yahoo.com> 2009-09-22 18:55:37 PDT ---
A bit more information on how we used the junit sampler.

Our test cases were mainly for IBM Ascential's MetaData Server. The goal was to
load the database with x records using a predefined object graph and ETL data
in XML format.

The setup would load that data using our persistence API and then start to run
the stress test. One of the stress tests measured performance degradation as
the database size increases, so we needed to keep state.

If the sampler creates a new instance of the class, we loose state. To get
around that, the custom runner was needed. A compromise would be to add a
checkbox to create a new instance with each call. This way, the user has the
option of using the same instance or creating a new instance.

hope that info is useful.

peter

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 47888] JUnit Sampler re-uses test object

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47888

--- Comment #1 from peter lin <wo...@yahoo.com> 2009-09-22 18:05:39 PDT ---
A couple of notes on the difference between jmeter's sampler and the standard
junit runner. For a stress test, we don't want to create a new instance of the
test class. When I originally wrote the junit sampler, it was for stress and
load testing. You can use it for unit testing, but it would require changing
how your unit test is written.

Cedric B of TestNG used to mention this design choice of JUnit as one of the
flaws. I got around the issue for stress testing by writing our own test
runner.

peter

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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