> I'm not looking for a tool to do memory analysis but more for a testing
> framework where I can set memory bounds. For example, I should be able
[quoted text clipped - 3 lines]
> thanks,
> n
These types of tests are not Unit tests, they are more Acceptance tests.
As in...
The application can handle 100 concurrent clients using no more than
256mb of heap space.
To automate a test against this requirement, I'd used something like FIT
or FitNesse.
They use HTML tables to describe the Acceptance Test, and then actually
launch the application.
Take a look at
http://fitnesse.org/FitNesse.TwoMinuteExample
James McGill - 18 Apr 2006 21:05 GMT
> To automate a test against this requirement, I'd used something like
> FIT
> or FitNesse.
Fit/Fitnesse looks so interesting, but it's SO hard to understand what
to do with it from their documentation. Maybe it makes more sense to
others, but I can't get my brain around it. I understand some *depth*
of it mind you, but that's not helpful until the *basics* are explained,
and the Fit/Fitnesse sites, pretty as they are, do a poor job of
explaining to a potential user, what the product is good for, and how to
begin using it.
Andrew McDonagh - 18 Apr 2006 21:06 GMT
>> I'm not looking for a tool to do memory analysis but more for a testing
>> framework where I can set memory bounds. For example, I should be able
[quoted text clipped - 20 lines]
>
> http://fitnesse.org/FitNesse.TwoMinuteExample
When writing the FitNesse testcase, you can specify how much heap the
JVM should use....
Tools like Fit & FitNesse are preferred for Acceptance Testing, as they
allow non-programmers to read & write testcases. They use the 'Domain
Specific Language' idea, which basically allows people who will use the
application, to know what the tests are doing, cause they are writtern
using the kind of words they would understand. Where as xUnit unit tests
are written in a programming language - which only programmers would
understand or be able to write new ones.
If you really want to use JUnit, then you can change the JVM parameters
of the JUnit session from within Eclipse's Run TestCase dialog. No doubt
other IDEs will allow the same.
Andrew
Andrew McDonagh - 18 Apr 2006 23:36 GMT
>> I'm not looking for a tool to do memory analysis but more for a testing
>> framework where I can set memory bounds. For example, I should be able
[quoted text clipped - 20 lines]
>
> http://fitnesse.org/FitNesse.TwoMinuteExample
Link to FIT
http://fit.c2.com/wiki.cgi?IntroductionToFit
Fit is the actual Framework for Integrated Tests, FitNesse is a simple
Wiki around Fit, that allows remote users to browser to the FIT server
and Run, create, edit, delete tests - amongst other cool things.
Andrew
nibblix - 20 Apr 2006 23:49 GMT
Consider the case where I have foo( ) having a peak heap usage of 150M.
I'd like to write a unit test case that ensures that future
refactoring/changes of foo() does not cause the heap to grow beyond
150M.
One way would be to set the Xmx to 150M but I'm looking for a way to do
this without causing the JVM to error out.
thanks,
n
Andrew McDonagh - 21 Apr 2006 01:13 GMT
> Consider the case where I have foo( ) having a peak heap usage of 150M.
> I'd like to write a unit test case that ensures that future
[quoted text clipped - 6 lines]
> thanks,
> n
There's no Unit Test reliable means of doing this.
The best you can do is use the Runtime memory methods to check that
current usage after running foo() is less than 150M. The problem with
this is that other factors may make the test pass or fail intermittently
- eg GC previous testcases mount up memory usage before GC can reclaimm etc.
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html
e.g.
public void testMemoryConsumptionIsBelowMaximumHeapSize() {
Runtime rt = Runtime.getRuntime();
assertTrue("Sanity test - starting memory is already beyond heap size
target", rt.totalMemory() < 150);
ClassUnderTest.foo();
assertTrue("Heap size target exceeded", rt.totalMemory() < 150);
}
It would also be a stress test of Foo() which is only being tested
within the single threaded nature of JUnit. It wouldn't be testing
Foo() in the nature of how it would be used in the application, where
other processing would be happening which might take memory consumption
over the limit.
nibblix - 24 Apr 2006 03:32 GMT
Very True.
Thanks for your input.
- n