<p>It' possible to use Junitperf with junit4?
I've a simplet Junit4 test class with several tests and I want to do a TimedTest on single test of that class. How can I do that?</p>

<p>To be more clear my Junit4 class is something like:</p>

<pre><code>public class TestCitta {

    @Test
    public void test1 {}

        @Test
    public void test2 {}
}
</code></pre>

<p>with junit3 i shold write something like:</p>

<pre><code>public class TestCittaPerformance {

    public static final long toleranceInMillis = 100;

    public static Test suite() {

        long maxElapsedTimeInMillis = 1000 + toleranceInMillis;

        Test testCase = new TestCitta("test2");

        Test timedTest = new TimedTest(testCase, maxElapsedTimeInMillis);

        return timedTest;
    }

    public static void main(String args[]) {
        junit.textui.TestRunner.run(suite());
    }
}
</code></pre>

<p>with Junit4?</p>

I had the same problem but was not lucky trying to make it run in different build environments. So I used the @Rule feature available since JUnit 4 to inject performance test invocation and requirements checking using annotations. It turned out to become a small library which replaced JUnitPerf in this project and I published it under the name
contiperf
. If you are interested in this approach, you can find it at
https://github.com/lucaspouzac/contiperf
.