Cornutum / tcases

A model-based test case generator
MIT License
218 stars 54 forks source link

OpenAPI: `multipleOf` in spec file - *RequestsTest (Junit/TestNG) are not generated #285

Closed sundarlogan closed 9 months ago

sundarlogan commented 10 months ago

Tcases Version: 4.0.2 OpenAPI Version: 3.0.0 OpenAPI Spec File: Attached petstore-multipleOf.json

Tried to generate Junit / TestNG API tests directly from the OpenAPI spec file using the Tcases cli cmd tcases-api-test -t=testng -p=test.petstore.testng ./Documents/petstore-multipleof.json and also via maven goal mvn tcases:api-test. It keeps loading - test not generated. If we remove/comment multipleOf in OpenAPI spec file *RequestsTest (Junit/TestNG) are generated.

sundarlogan commented 9 months ago

Hi @kerrykimbrough Can you pls. help me with this. Is there any workaround to try?

kerrykimbrough commented 9 months ago

Hi, Sundaravel, thanks for reporting this issue. I'm investigating now.

kerrykimbrough commented 9 months ago

This problem is caused by a defect in the algorithm for creating a failure case using a petPrice value that is not a multiple of 0.01. Look for a fix soon.

Meanwhile, you can work around the problem with a change to the schema for petPrice: define a maximum or minimum value with more than 2 fractional digits. For example: "maximum": 0.123.

sundarlogan commented 9 months ago

Thank you @kerrykimbrough will try & use this work around..

kerrykimbrough commented 9 months ago

Fixed in version 4.0.3

sundarlogan commented 8 months ago

@kerrykimbrough This fix works, able to generate tests with multipleOf.

But, when we add minimum & maximum values with multipleOf - facing issue (It keeps loading - test not generated) Any one - minimum or maximum with multipleOf, it works.

Updated OpenAPI Spec File -- petstore-multipleOf-updated.json

kerrykimbrough commented 8 months ago

But, when we add minimum & maximum values with multipleOf - facing issue (It keeps loading - test not generated)

I can't reproduce this problem. Which version of Tcases are you using?

sundarlogan commented 8 months ago

@kerrykimbrough Apologies, attached the wrong sample file. Can you pls. check with this file - payment-multipleOf-updated.json Using latest tcases version 4.0.4

kerrykimbrough commented 8 months ago

Here's the problem. When a numeric schema specifies both minimum and maximum (i.e. a bounded range), Tcases calculates the number of possible multiples within the range. (This is for the purpose of checking consistency with other schema constraints.) But in your example, because the maximum is so large, the number of possible multiples is enormous. Tcases isn't stuck -- it's just taking a really, really, really long time to count up all the multiples.

For now, you can work around the problem by using a smaller maximum. Meanwhile, I'm investigating a change to speed up the counting.

kerrykimbrough commented 8 months ago

Fixed in release 4.0.5