Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In the report not only parameters appear in cases section but also a list parameter of a stage method #161

Closed
girardot opened this issue Nov 3, 2015 · 7 comments
Milestone

Comments

@girardot
Copy link

girardot commented Nov 3, 2015

In the report of this sample the discount periods (simple POJO object list) appear in cases section like that :
bdd.model.DiscountPeriod@45f45fa1, bdd.model.DiscountPeriod@4c6e276e

DiscountPeriod list is not a parameter of the test, so it seems strange that it appears in the report.

  @DataProvider({
            "ORANGE, ORANGE",
            "CHERRY, CHERRY"
    })
    @Test
    public void should_display_report_with_discount_period(final FruitType fruitType, final String expectedFruitType) {
        given().a_fruit_order_of_(fruitType)
               .with().a_quantity(12);

        when().a_fruit_order_is_mapped();

        then().the_mapped_market_order_type_is(expectedFruitType)
              .and().with_a_discount_period_of(
                DiscountPeriod.of(of(2015, 11, 5), of(2015, 11, 24)),
                DiscountPeriod.of(of(2015, 12, 5), of(2015, 12, 24))
        );
    }
public ThenTheMarketReceivesOrder with_a_discount_period_of(@Table(columnTitles = {"Start Date", "End Date"})
                                                                DiscountPeriod... discountPeriods) {

        // good assertions here ...

        return self();
    }

Give the report :
(with discountPeriods bdd.model.DiscountPeriod@45f45fa, bdd.model.DiscountPeriod@4c6e276)

 Scenario: should display report with discount period

   Given a fruit order of  <fruitType>
    With a quantity 12
    When a fruit order is mapped
    Then the mapped market order type is <fruitType>
     And with a discount period of

     | Start Date | End Date   |
     +------------+------------+
     | 2015-11-05 | 2015-11-24 |
     | 2015-12-05 | 2015-12-24 |


  Cases:

    | # | fruitType | discountPeriods                                                      | Status  |
    +---+-----------+----------------------------------------------------------------------+---------+
    | 1 | ORANGE    | bdd.model.DiscountPeriod@45f45fa1, bdd.model.DiscountPeriod@4c6e276e | Success |
    | 2 | CHERRY    | bdd.model.DiscountPeriod@3a079870, bdd.model.DiscountPeriod@3b2cf7ab | Success |

If we override equals, hashCode or toString methods discountPeriods disappear of the cases section. .

@janschaefer
Copy link
Contributor

Yes, I agree that should not be the case. It is a bit related to #86.

@janschaefer janschaefer added this to the v0.9.5 milestone Nov 3, 2015
@girardot
Copy link
Author

girardot commented Nov 3, 2015

Thank you for your quick answers.

Correct me if I am wrong but the difference between the two issues is :

@janschaefer
Copy link
Contributor

Yes, I agree they are completely different. They only both have to do with the @Table annotation

@janschaefer
Copy link
Contributor

I reopend this issue, because the fix might actually be more difficult than I first expect.

@janschaefer
Copy link
Contributor

If you do not implement the equals method and create a different object in each case, than it is difficult for JGiven to find out whether the values are actually the same between each run. If they are not the same, however, JGiven has to create multiple cases for that. I will have to think about that issue a bit more, I guess :-)

@girardot
Copy link
Author

girardot commented Nov 6, 2015

Ok I understand the point with equals method, we will do that, thank you.

@janschaefer
Copy link
Contributor

I fixed the issue now. It is not even necessary anymore to implement the equals method as JGiven takes the content of the table directly for comparison.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants