Search in sources :

Example 11 with PotentialAssignment

use of org.junit.experimental.theories.PotentialAssignment in project junit4 by junit-team.

the class PotentialAssignmentTest method shouldUseQuotedValueInDescription.

@Test
public void shouldUseQuotedValueInDescription() throws CouldNotGenerateValueException {
    String name = "stringDatapoint";
    Object value = new Object() {

        @Override
        public String toString() {
            return "string value";
        }
    };
    PotentialAssignment assignment = PotentialAssignment.forValue(name, value);
    assertEquals("\"string value\" <from stringDatapoint>", assignment.getDescription());
}
Also used : PotentialAssignment(org.junit.experimental.theories.PotentialAssignment) Test(org.junit.Test)

Example 12 with PotentialAssignment

use of org.junit.experimental.theories.PotentialAssignment in project junit4 by junit-team.

the class PotentialAssignmentTest method shouldReturnGivenValue.

@Test
public void shouldReturnGivenValue() throws CouldNotGenerateValueException {
    Object value = new Object();
    PotentialAssignment assignment = PotentialAssignment.forValue("name", value);
    assertEquals(value, assignment.getValue());
}
Also used : PotentialAssignment(org.junit.experimental.theories.PotentialAssignment) Test(org.junit.Test)

Example 13 with PotentialAssignment

use of org.junit.experimental.theories.PotentialAssignment in project junit4 by junit-team.

the class TestedOnSupplierTest method descriptionStatesParameterName.

@Test
public void descriptionStatesParameterName() throws Exception {
    TestedOnSupplier supplier = new TestedOnSupplier();
    List<PotentialAssignment> assignments = supplier.getValueSources(signatureOfFoo());
    assertThat(assignments.get(0).getDescription(), is("\"1\" <from ints>"));
}
Also used : PotentialAssignment(org.junit.experimental.theories.PotentialAssignment) TestedOnSupplier(org.junit.experimental.theories.suppliers.TestedOnSupplier) Test(org.junit.Test)

Example 14 with PotentialAssignment

use of org.junit.experimental.theories.PotentialAssignment in project junit4 by junit-team.

the class AllMembersSupplierTest method dataPointsAnnotationMeansTreatAsArrayOnly.

@Test
public void dataPointsAnnotationMeansTreatAsArrayOnly() throws Throwable {
    List<PotentialAssignment> assignments = potentialAssignments(HasDataPointsWithObjectParameter.class.getMethod("theory", Object.class));
    assertEquals(2, assignments.size());
    for (PotentialAssignment assignment : assignments) {
        assertNotEquals(HasDataPointsWithObjectParameter.objectField, assignment.getValue());
    }
}
Also used : PotentialAssignment(org.junit.experimental.theories.PotentialAssignment) Test(org.junit.Test)

Aggregations

PotentialAssignment (org.junit.experimental.theories.PotentialAssignment)14 Test (org.junit.Test)13 SpecificDataPointsSupplier (org.junit.experimental.theories.internal.SpecificDataPointsSupplier)6 TestClass (org.junit.runners.model.TestClass)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 ParameterSignature (org.junit.experimental.theories.ParameterSignature)1 TestedOnSupplier (org.junit.experimental.theories.suppliers.TestedOnSupplier)1