You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 ''concurrentScopeAdditionsAndRemovals_shouldNotCrash()'' in ''ScopeTreeManipulationsMultiThreadTest.java''.
But generating random numbers in test code is not a good test practice.
Because 1. using a random number generator in test code makes the test non-deterministic since it is hard to know which random number causes when the test case fails.
2. Random number generation can create couplings between classes and timing artifacts because most random number generator classes are thread-safe and therefore introduce additional synchronization.
So, a potential problem is that a test that should fail due to incorrect synchronization in the class under test might pass because of synchronization in the RNG used in the test code.
3. cost too many resources.
In your code, you use the random number in the if-condition, but why not just test the edge cases instead of using a random number generator? You can test your code under input value = 49, 50, 51.
if (random.nextInt(100) < 50) {
runnable = new RemoveNodeThread(ROOT_SCOPE);
} else {
runnable = new AddNodeThread(ROOT_SCOPE);
}
The text was updated successfully, but these errors were encountered:
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 ''concurrentScopeAdditionsAndRemovals_shouldNotCrash()'' in ''ScopeTreeManipulationsMultiThreadTest.java''.
But generating random numbers in test code is not a good test practice.
Because 1. using a random number generator in test code makes the test non-deterministic since it is hard to know which random number causes when the test case fails.
2. Random number generation can create couplings between classes and timing artifacts because most random number generator classes are thread-safe and therefore introduce additional synchronization.
So, a potential problem is that a test that should fail due to incorrect synchronization in the class under test might pass because of synchronization in the RNG used in the test code.
3. cost too many resources.
In your code, you use the random number in the if-condition, but why not just test the edge cases instead of using a random number generator? You can test your code under input value = 49, 50, 51.
if (random.nextInt(100) < 50) {
runnable = new RemoveNodeThread(ROOT_SCOPE);
} else {
runnable = new AddNodeThread(ROOT_SCOPE);
}
The text was updated successfully, but these errors were encountered: