Skip to content

imp(tests): refactor table driven tests #881

@rnbguy

Description

@rnbguy

Improvement Summary

Currently, some of the rust tests contain a group of table/data-driven tests. These tests will fail if one in the group fails.

https://github.com/cosmos/ibc-rs/blob/c83f26aeb87004ca464917e250da62ba3e92238b/crates/ibc/src/applications/transfer/coin.rs#L125-L148

We want to treat each testcases individually. If one fails, the others in the group may continue.

Proposal

The current Rust release doesn't support this feature. The common opinion in the Rust community is to keep each testcases in a separate test method, potentially using a macro.

We don't want to implement/maintain our macro. So we will use rstest as a solution. The following is a refactored code of the above example using rstest.

https://github.com/cosmos/ibc-rs/blob/1aa853bb646d37aab3848096b4221450f3a2e760/crates/ibc/src/applications/transfer/coin.rs#L144-L159

Metadata

Metadata

Assignees

Labels

O: code-hygieneObjective: aims to improve code hygieneO: maintainabilityObjective: cause to ease modification, fault corrections and improve code understandingO: testingObjective: aims to improve testing coverage

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions