views:

128

answers:

2

I am writing a unit test to check that a private method will close a stream.

The unit test calls methodB and the variable something is null

The unit test doesn't mock the class on test

The private method is within a public method that I am calling.

Using emma in eclipse (via the eclemma plugin) the method call is displayed as not being covered even though the code within the method is

e.g

public methodA(){

    if (something==null) {
        methodB(); //Not displayed as covered
    }
}

private methodB(){
    lineCoveredByTest; //displayed as covered
}

Why would the method call not be highlighted as being covered?

A: 

I assume when you say 'the unit test calls methodB()', you mean not directly and via methodA().

So, is it possible methodB() is being called elsewhere, by another unit test or methodC() maybe?

Stu Thompson
+1  A: 

I have found that the eclipse plugin for EMMA is quite buggy, and have had similar experiences to the one you describe. Better to just use EMMA on its own (via ANT if required). Make sure you always regenerate the metadata files produced by EMMA, to avoid merging confusion (which I suspect is the problem with the eclipse plugin).

fivemile