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"));
}
use of org.junit.experimental.theories.PotentialAssignment in project junit4 by junit-team.
the class SpecificDataPointsSupplierTest method shouldReturnOnlyTheNamedSingleFieldDataPoints.
@Test
public void shouldReturnOnlyTheNamedSingleFieldDataPoints() throws Throwable {
SpecificDataPointsSupplier supplier = new SpecificDataPointsSupplier(new TestClass(TestClassWithNamedDataPoints.class));
List<PotentialAssignment> assignments = supplier.getValueSources(signature("methodWantingNamedSingleFieldString"));
List<String> assignedStrings = getStringValuesFromAssignments(assignments);
assertEquals(1, assignedStrings.size());
assertThat(assignedStrings, hasItem("named single value"));
}
use of org.junit.experimental.theories.PotentialAssignment in project junit4 by junit-team.
the class SpecificDataPointsSupplierTest method shouldReturnOnlyTheNamedMethodDataPoints.
@Test
public void shouldReturnOnlyTheNamedMethodDataPoints() throws Throwable {
SpecificDataPointsSupplier supplier = new SpecificDataPointsSupplier(new TestClass(TestClassWithNamedDataPoints.class));
List<PotentialAssignment> assignments = supplier.getValueSources(signature("methodWantingNamedMethodString"));
List<String> assignedStrings = getStringValuesFromAssignments(assignments);
assertEquals(1, assignedStrings.size());
assertThat(assignedStrings, hasItem("named method"));
}
use of org.junit.experimental.theories.PotentialAssignment in project junit4 by junit-team.
the class SpecificDataPointsSupplierTest method shouldReturnOnlyTheNamedDataPoints.
@Test
public void shouldReturnOnlyTheNamedDataPoints() throws Throwable {
SpecificDataPointsSupplier supplier = new SpecificDataPointsSupplier(new TestClass(TestClassWithNamedDataPoints.class));
List<PotentialAssignment> assignments = supplier.getValueSources(signature("methodWantingAllNamedStrings"));
List<String> assignedStrings = getStringValuesFromAssignments(assignments);
assertEquals(4, assignedStrings.size());
assertThat(assignedStrings, hasItems("named field", "named method", "named single value", "named single method value"));
}
use of org.junit.experimental.theories.PotentialAssignment in project junit4 by junit-team.
the class WithNamedDataPoints method onlyUseSpecificDataPointsIfSpecified.
@Test
public void onlyUseSpecificDataPointsIfSpecified() throws Throwable {
List<PotentialAssignment> assignments = potentialAssignments(HasSpecificDatapointsParameters.class.getMethod("theory", String.class));
assertEquals(5, assignments.size());
for (PotentialAssignment assignment : assignments) {
assertThat((String) assignment.getValue(), containsString("expected"));
}
}
Aggregations