spring-cloud / spring-cloud-contract

Support for Consumer Driven Contracts in Spring
https://cloud.spring.io/spring-cloud-contract
Apache License 2.0
720 stars 440 forks source link

autogenerated test failed in case when there are empty and not empty arrays with the same names #880

Closed dev-priporov closed 4 years ago

dev-priporov commented 5 years ago

If autogenerated test gets an expected body with 2 arrays with the same names, but one of them is an empty, the test will failed. Seems that the trouble is in jsonassert actually, but I think SCC should avoid that problem. The screen shows the line where the test fails. image

  springBootVersion = '2.1.2.RELEASE'
  springCloudContractVersion = '2.0.1.RELEASE'
  springCloudVersion = 'Greenwich.RELEASE' 

Also I made a simple git project which helps to reproduce the issue: https://github.com/dev-priporov/scc-empty-array-issue

OlgaMaciaszek commented 5 years ago

Hi, @dev-priporov thanks for reporting it. This is, indeed, a bug. At the same time, this use-case seems to be a rather rare corner-case. So we are going to fix it, but not as a priority. In the meantime, we suggest providing BodyMatchers as a workaround (and in the jsonPath, specifying the array element indexes for each match).

marcingrzejszczak commented 5 years ago

Is this problem still open? I think we've fixed a similar issue in the meantime. @dev-priporov can you check out the latest snapshots please?

dev-priporov commented 5 years ago

@marcingrzejszczak I will check late, sorry now really have no time for that

spring-projects-issues commented 5 years ago

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

epm-dev-priporov commented 5 years ago

@marcingrzejszczak Hi, sorry for making that so late. I've updated the version and tried check the issue, but seems that now generated contract test is invalid.

image

to reproduce that you can use https://github.com/dev-priporov/scc-empty-array-issue project

OlgaMaciaszek commented 5 years ago

Hi @epm-dev-priporov Thanks; looks like a bug. We will work on a fix.