Skip to content

Commit

Permalink
Really mostly for coverage ;)
Browse files Browse the repository at this point in the history
  • Loading branch information
oc committed Jun 9, 2010
1 parent afe5000 commit c9ceeb7
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/test/java/no/muda/jackbox/MethodRecordingTest.java
@@ -0,0 +1,34 @@
package no.muda.jackbox;

import no.muda.jackbox.example.ExampleRecordedObject;
import org.junit.Before;
import org.junit.Test;

import java.lang.reflect.Method;

import static org.fest.assertions.Assertions.assertThat;

public class MethodRecordingTest {
private Method method;
private MethodRecording recording;

@Before
public void methodSetup() throws NoSuchMethodException {
method = ExampleRecordedObject.class.getMethod("exampleMethod", Integer.TYPE, Integer.TYPE);
recording = new MethodRecording(ExampleRecordedObject.class, method, new Object[] { 5, 6 });
recording.setReturnValue(11);
}

@Test
public void shouldUseHashCodeOfRecordedMethod() throws NoSuchMethodException {
assertThat(recording.hashCode()).isEqualTo(method.hashCode());
}

@Test
public void shouldHaveTheMostImportantValuesInItsToString() {
assertThat(recording.toString())
.contains("exampleMethod(int,int)")
.contains("arguments=[5, 6]")
.contains("returnValue=11");
}
}

2 comments on commit c9ceeb7

@mkotsbak
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How large is the coverage now? Should be pretty good I think.

@jhannes
Copy link
Contributor

@jhannes jhannes commented on c9ceeb7 Jun 9, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my IDE, it reports 90% coverage of production code lines. Considering that a lot of the uncovered bits are checked exceptions that can never happen, this is pretty good.

Please sign in to comment.