ethereum / ethereumj

DEPRECATED! Java implementation of the Ethereum yellowpaper. For JSON-RPC and other client features check Ethereum Harmony
GNU Lesser General Public License v3.0
2.18k stars 1.09k forks source link

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

Open TestSmell opened 1 year ago

TestSmell commented 1 year ago

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 commented 1 year ago

这是来自QQ邮箱的假期自动回复邮件。您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。