Skip to content

[Naming] System under Test should not be called "mock" #1320

Open
@fleupold

Description

@fleupold

When a solidity library is unit tested, it needs to be wrapped in a smart contract in order to be exposed for the js unit testing framework. The OpenZeppelin framework chose to call these wrapping contracts Mocks, e.g.

https://github.com/OpenZeppelin/openzeppelin-solidity/blob/b644c72eb083d7a84a5c9924ec8012a7c29290fd/contracts/mocks/MathMock.sol#L7-L19

They are used in unit tests like this:

https://github.com/OpenZeppelin/openzeppelin-solidity/blob/20cf88543024fb95d79db16a2d7a3d1c32090e2a/test/library/Math.test.js#L13-L15

I think the name mock is quite confusing in this context. In traditional unit testing mocks are used to simulate behaviour of complex dependencies that the system under test (SUT) depends on.
Here we are calling the SUT itself a mock, which seems like an anti-pattern. The SUT should never be mocked, as it's the thing we are testing.

To avoid confusion, would it be acceptable to rename the contracts that are wrapping the libraries, e.g. instead of MathMock something like MathProxy, MathFacade or MathWrapper?

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTest suite and helpers.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions