cweill / gotests

Automatically generate Go test boilerplate from your source code.
Apache License 2.0
4.93k stars 346 forks source link

Generate test cases #111

Open johnfercher opened 4 years ago

johnfercher commented 4 years ago

First of all, very nice your project. I would like to contribute too, and I have some questions.

Do you have plans to generate the test cases too? Would be difficult to do it?

Do you have plans to generate separated test functions instead of the table style?

cweill commented 4 years ago

@johnfercher Thank you for your kind words. Unfortunately, these days I mostly write Python, so you likely are getting more use out of this project than I am. Nevertheless, I'm happy to answer your questions:

Do you have plans to generate the test cases too? Would be difficult to do it?

I believe that generating test cases is more difficult than generating the test boilerplate. The latter can be done deterministically by parsing a method-under-test's signature and building its AST, then writing the boilerplate from it. Conversely, the former requires understanding the code being tested, and I'm not sure how you would do that in a way that isn't terribly complex.

If you have any suggestions, I'm open to hearing them. :)

Do you have plans to generate separated test functions instead of the table style?

The table-driven style is the one that the Go-team recommends. Of course, if you think it would be better to have a non-table-driven style, I'll accept a PR for that.

Pissssofshit commented 3 years ago

First of all, very nice your project. I would like to contribute too, and I have some questions.

Do you have plans to generate the test cases too? Would be difficult to do it?

Do you have plans to generate separated test functions instead of the table style?

Do you got any idea of how to generate the test case ? I'm very curious about that.

cweill commented 3 years ago

The long-term vision for this project is for it to generate test code, including test cases, for you automatically based on the signature and high level description.

With OpenAI's recent release of GPT-3 on May 2020 which can generate high quality code that actually compiles, generating Golang test cases may actually be feasible! Here are some repos that use GPT-3 to generate code.

If anyone has ML expertise, and is looking for a cool project, I think this has a ton of potential. I just wish I had the cycles to work on it myself...