As we all aware about smart contract testing using truffle framework. Currently, we are writing the test scripts either in solidity or in java-script manually. Is there any way so that I can auto generate the test scripts for my smart contracts without doing hard coding?? What are the APIs for smart contracts? How to use those APIs?

Eventually, I want to develop a generic code which is capable of writing test scripts for smart contracts automatically, for which I just have to set the test cases in modular ways.

  • 2
    A positive answer (yes) would imply that the halting problem is solvable. So I would say that the answer is no. – goodvibration Apr 16 '19 at 13:41

This question inspired me to create truffle-test-generator. It's not perfect, and follows my own style-guide for Truffle tests, but it should be useful for getting the initial boilerplate of a Truffle test done. It reads the json file of your compiled contracts and creates a describe block for all external and public functions. It can also create the input parameters for your constructor, you'll just have to set the initial values.


You are the one who knows what your smart contract functions need to do. It is not possible to generate test scripts for your functionality without you specifying the requirements for your functions. I guess you could create a tool that would allow you to specify these requirements in some sort of JSON format or some DSL, but ultimately I doubt that such a tool will save you a lot of time over just specifying your requirements directly with unit tests.

  • Is there any testing tool which is capable of handling smart contracts and can generate test scripts for given contracts based on function present in that contract? End user only need to provide contract & test scenarios/cases to the tool from which test scripts should be auto generated without any human intervention. Is it possible to develop such a tool?If yes, How? Did any one worked/explore on this before? – John Carter Apr 25 '19 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.