Search in sources :

Example 6 with PotentialAssignment

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"));
}
Also used : SpecificDataPointsSupplier(org.junit.experimental.theories.internal.SpecificDataPointsSupplier) TestClass(org.junit.runners.model.TestClass) PotentialAssignment(org.junit.experimental.theories.PotentialAssignment) Test(org.junit.Test)

Example 7 with PotentialAssignment

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"));
}
Also used : SpecificDataPointsSupplier(org.junit.experimental.theories.internal.SpecificDataPointsSupplier) TestClass(org.junit.runners.model.TestClass) PotentialAssignment(org.junit.experimental.theories.PotentialAssignment) Test(org.junit.Test)

Example 8 with PotentialAssignment

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"));
}
Also used : SpecificDataPointsSupplier(org.junit.experimental.theories.internal.SpecificDataPointsSupplier) TestClass(org.junit.runners.model.TestClass) PotentialAssignment(org.junit.experimental.theories.PotentialAssignment) Test(org.junit.Test)

Example 9 with PotentialAssignment

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"));
}
Also used : SpecificDataPointsSupplier(org.junit.experimental.theories.internal.SpecificDataPointsSupplier) TestClass(org.junit.runners.model.TestClass) PotentialAssignment(org.junit.experimental.theories.PotentialAssignment) Test(org.junit.Test)

Example 10 with PotentialAssignment

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"));
    }
}
Also used : PotentialAssignment(org.junit.experimental.theories.PotentialAssignment) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) 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