Share on Twitter
Share on Facebook
Share on Reddit
Share via Email
Share on LinkedIn
Share via RSS

NGD Enterprise head John deVadoss recently published an article introducing the benefits of a test-driven development (TDD) approach. After introducing the paradigm, deVadoss breaks down how the techniques can be used to reduce the time spent debugging and what the team is doing to bring TDD to Neo blockchain developers.

Test-Driven Development

As the name implies, TDD places testing at the forefront, unlike the legacy development approach of developing software and then going back through and testing it. After establishing requirements for a project, the developer should write a set of unit tests that defines expected behavior for the different pieces of functionality.

Once the tests have been created, the developer then moves on to actually implementing the functionality, attempting to get all the tests to pass. Once this is achieved, the code is then refactored with a focus on simplification and code comprehension. This sequence of steps can be repeated any number of times.

Coupled with good version control tools, this is intended to result in fast development cycles. Any breaking changes can be quickly reverted to the last state where tests were successfully passing. As a result, developers can spend less time debugging faulty new code and more time iterating on code that already works.

TDD & the Neo Blockchain Toolkit

deVadoss notes that the decentralized nature of blockchain-based applications make them naturally ill-suited to the test-first approach. The NGD Enterprise team is currently working on a range of improvements to the Neo Blockchain Toolkit to help bridge the gap.

The introduction to test-driven development coincides with recent efforts by chief architect Harry Pierson to deliver a framework for the automated testing of Neo smart contracts. This is enabled through a number of new tools and libraries, including Neo Test Harness for executing tests, and Neo Assertions, an extension for the Fluent Assertions library that provides custom assertions for Neo-specific types such as StackItem and StorageItem.

The new testing architecture can be found under the neo-test repository. Developers wanting to test its capabilities can get started using a number of examples provided by Pierson. Provided samples include a domain registry contract, oracle request, and NEP-17 token.

These samples will enable developers to test out the optimized “inner loop” enabled through the tools. Running the test command will build the contract and deploy it on a new private network instance before executing the tests which verify the contract is behaving as expected.