Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
TestSmell opened this issue Aug 17, 2022 · 1 comment

Comments

@TestSmell
Copy link

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
@erockoms
Copy link

erockoms commented Aug 17, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants