OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
20.56k stars 6.28k forks source link

Restore java test code in samples #247

Open jmini opened 6 years ago

jmini commented 6 years ago

@cbornet :

The commit d9fe34a removed all the java samples test code

jmini commented 6 years ago

The real commit (the one included on the master branch) is c8c316e41ee85a3ba1de4c39559eb8cf9a1690e4.


Git command to see what was modified with this commit:

git diff 5340c35ce123c18daa82f62131b3d1606bd1ceab..c8c316e41ee85a3ba1de4c39559eb8cf9a1690e4 --name-status

I will analyze the results.

jmini commented 6 years ago

I did some analysis and I propose to restore following files at commit c8c316e41ee85a3ba1de4c39559eb8cf9a1690e4 (see the list at the end of this message)

See my commit: https://github.com/jmini/openapi-generator/commit/ce671d85ac26391bb7109a842822661f689dc985

Feedback is welcome. @cbornet : have you other files in mind?

I will soon open a PR: issue247_restore-unit-test ->master.


cbornet commented 6 years ago

There should also be tests for the petstore (PetApiTest, StoreApiTest, UserApiTest)

jmini commented 6 years ago

Ok I definitively need more background on this. The generated stuff is still there:

Before my commit:

Now the file still exists (introduced with e0b0248c3884daf293a1589edf7171afc6339845)

The package names have changed, but this is documented: New default values for the generated code


What was lost during the process are the manual written Unit tests, that are added to the sample after code generation. I thought this issue is about restoring them.


Please continue the discussion. I am not sure I got everything right.

cbornet commented 6 years ago

The tests you see are the auto-generated tests. But for the samples we had true implementations of tests with actual assertions validating the responses. The scripts normally prevent overriding these files during generation. These tests allow to validate the generated code more deeply.

cbornet commented 6 years ago

See this diff for a part of the code that was removed.

jmini commented 6 years ago

First part: https://github.com/OpenAPITools/openapi-generator/pull/346 (can be merged without waiting for the second part).


In an other PR I will restore the removed implementation that @cbornet would like to have.

cbornet commented 5 years ago

Did you progress on that ? We still don't have good CI tests on our Java clients...

jmini commented 5 years ago

I started it twice (there is a branch on my fork), but it requires some time to do it properly (to sort out what needs to be rested and what not).

The setup with the local host table (see this page) is also complicated for me (never took the time to do the setup locally)

I also wanted to run the petstore server directly (without docker), but nobody replied to the change proposed here https://github.com/OpenAPITools/openapi-petstore/pull/6 (the ultimate goal is to build the petstore server and to deploy a released artifact on Maven Central - this way we can fetch it and start it on the JVM, no docker and port mapping involved)


I my opinion working on a solution as described in #689 would add more value than working on this (which does not imply that I will not solve this, both approaches are complementary)

cbornet commented 5 years ago

We should work on this issue...