Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Test Smell: it is not a good practice to introduce nondeterministic randomness in test code #1305

@TestSmell

Description

@TestSmell

Hi!

We notice that the random number generator (RNG) is used to produce test code in your project.
For example, a random generator in the test method named ''testInvalidTransaction() '' in ''PendingStateTest.java''
截屏2022-08-17 下午6 37 23

But generating random data in test code is not a good test practice. Since Using randomized data may lead to unexpected unit test failure and once the test case fails, it is hard to trace what test data causes it.

Solution:
There are two solutions:

  1. set a random seed number for your random generator
  2. using a hash method to generate random data

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions