Permalink
Browse files

adding tests

  • Loading branch information...
1 parent 0981e7a commit 096cc8bb7f8b9dfb44bd24624448a4121380c283 @pholser pholser committed with Nov 2, 2010
View
45 pom.xml
@@ -39,6 +39,12 @@
<artifactId>junit</artifactId>
<version>4.8.2</version>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.8.5</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
@@ -51,6 +57,45 @@
<target>1.6</target>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <configuration>
+ <check>
+ <haltOnFailure>true</haltOnFailure>
+ <branchRate>100</branchRate>
+ <totalBranchRate>100</totalBranchRate>
+ <totalLineRate>100</totalLineRate>
+ </check>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>clean</goal>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>javancss-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <configuration>
+ <formats>
+ <format>xml</format>
+ <format>html</format>
+ </formats>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
</project>
@@ -0,0 +1,17 @@
+package com.pholser.junit.parameters.internal.extractors;
+
+import com.pholser.junit.parameters.random.SourceOfRandomness;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+public class ExtractingABooleanValueFromASourceOfRandomnessTest {
+ @Test
+ public void interaction() {
+ SourceOfRandomness random = mock(SourceOfRandomness.class);
+ when(random.nextBoolean()).thenReturn(true);
+
+ assertTrue(new BooleanExtractor().randomValue(random));
+ }
+}
@@ -0,0 +1,17 @@
+package com.pholser.junit.parameters.internal.extractors;
+
+import com.pholser.junit.parameters.random.SourceOfRandomness;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+public class ExtractingAByteValueFromASourceOfRandomnessTest {
+ @Test
+ public void interaction() {
+ SourceOfRandomness random = mock(SourceOfRandomness.class);
+ when(random.nextInt()).thenReturn(20);
+
+ assertEquals(Byte.valueOf("20"), new ByteExtractor().randomValue(random));
+ }
+}
@@ -0,0 +1,17 @@
+package com.pholser.junit.parameters.internal.extractors;
+
+import com.pholser.junit.parameters.random.SourceOfRandomness;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+public class ExtractingACharacterValueFromASourceOfRandomnessTest {
+ @Test
+ public void interaction() {
+ SourceOfRandomness random = mock(SourceOfRandomness.class);
+ when(random.nextInt()).thenReturn(60);
+
+ assertEquals(Character.valueOf('<'), new CharacterExtractor().randomValue(random));
+ }
+}

0 comments on commit 096cc8b

Please sign in to comment.