use of org.junit.experimental.theories.PotentialAssignment in project junit4 by junit-team.
the class PotentialAssignmentTest method shouldIncludeFailureInDescriptionIfToStringFails.
@Test
public void shouldIncludeFailureInDescriptionIfToStringFails() throws CouldNotGenerateValueException {
String name = "explodingValue";
Object value = new Object() {
@Override
public String toString() {
throw new RuntimeException("Oh no!");
}
};
PotentialAssignment assignment = PotentialAssignment.forValue(name, value);
assertEquals("[toString() threw RuntimeException: Oh no!] <from explodingValue>", assignment.getDescription());
}
use of org.junit.experimental.theories.PotentialAssignment in project junit4 by junit-team.
the class PotentialAssignmentTest method shouldNotUseQuotesForNullValueDescriptions.
@Test
public void shouldNotUseQuotesForNullValueDescriptions() throws CouldNotGenerateValueException {
String name = "nullDatapoint";
Object value = null;
PotentialAssignment assignment = PotentialAssignment.forValue(name, value);
assertEquals("null <from nullDatapoint>", assignment.getDescription());
}
use of org.junit.experimental.theories.PotentialAssignment in project junit4 by junit-team.
the class SpecificDataPointsSupplierTest method shouldReturnOnlyTheNamedSingleMethodDataPoints.
@Test
public void shouldReturnOnlyTheNamedSingleMethodDataPoints() throws Throwable {
SpecificDataPointsSupplier supplier = new SpecificDataPointsSupplier(new TestClass(TestClassWithNamedDataPoints.class));
List<PotentialAssignment> assignments = supplier.getValueSources(signature("methodWantingNamedSingleMethodString"));
List<String> assignedStrings = getStringValuesFromAssignments(assignments);
assertEquals(1, assignedStrings.size());
assertThat(assignedStrings, hasItem("named single method value"));
}
use of org.junit.experimental.theories.PotentialAssignment in project junit4 by junit-team.
the class SpecificDataPointsSupplierTest method shouldReturnNothingIfTheNamedDataPointsAreMissing.
@Test
public void shouldReturnNothingIfTheNamedDataPointsAreMissing() throws Throwable {
SpecificDataPointsSupplier supplier = new SpecificDataPointsSupplier(new TestClass(TestClassWithNamedDataPoints.class));
List<PotentialAssignment> assignments = supplier.getValueSources(signature("methodWantingWrongNamedString"));
List<String> assignedStrings = getStringValuesFromAssignments(assignments);
assertEquals(0, assignedStrings.size());
}
use of org.junit.experimental.theories.PotentialAssignment in project junit4 by junit-team.
the class SpecificDataPointsSupplierTest method shouldReturnOnlyTheNamedFieldDataPoints.
@Test
public void shouldReturnOnlyTheNamedFieldDataPoints() throws Throwable {
SpecificDataPointsSupplier supplier = new SpecificDataPointsSupplier(new TestClass(TestClassWithNamedDataPoints.class));
List<PotentialAssignment> assignments = supplier.getValueSources(signature("methodWantingNamedFieldString"));
List<String> assignedStrings = getStringValuesFromAssignments(assignments);
assertEquals(1, assignedStrings.size());
assertThat(assignedStrings, hasItem("named field"));
}
Aggregations