gnolang / gno

Gno: An interpreted, stack-based Go virtual machine to build succinct and composable apps + Gno.land: a blockchain for timeless code and fair open-source
https://gno.land/
Other
841 stars 342 forks source link

RFC(gnovm): make all gno unit tests independent (and parallel) #2376

Open moul opened 1 week ago

moul commented 1 week ago

In Go, unit tests can share state, and developers need to manually reset the state. While we can follow the same approach, I propose a shift to make unit tests more independent by default. This involves running a new fresh gno.Machine for each test, ensuring no shared state and allowing tests to run in parallel.

With independent tests, we can safely run all tests in parallel, speeding up the testing process. Additionally, this ensures that gno test -run XXX is consistent, with no test dependencies. Another benefit is that it makes it harder to have implicit or hard-to-read dependencies between tests, improving the overall readability and maintainability of the test suite.

A potential need will be to show more examples of "flows" by writing subtests or test suites (a single TestXXX with several steps). However, this doesn't seem like a big deal compared to the benefits of having independent and parallel tests. This issue is an RFC, so please share your thoughts and feedback on this proposal.