RipMeApp / ripme

Downloads albums in bulk
MIT License
3.67k stars 624 forks source link

Test Smell: it is not a good test practice to use the loop in the test #1989

Open TestSmell opened 1 year ago

TestSmell commented 1 year ago

Hi!

you use the loop structure in your test cases. For example, testScrolllerGID() in CyberdropRipperTest.java

image

However, using the loop in test cases is not a good test practice.

We analyzed the relevant Stack Overflow posts and summarized four potential negatives it brings:

  1. Loops make the test case more complex.
  2. In most cases, a loop can be replaced with a data-driven test that is more readable.
  3. Loops break the assert-for-one-thing thumb rule. I don't mean a single assert statement.
  4. When a test fails, knowing the reason is more complicated.

Solution: To avoid using the loop in the test, JUnit provides an annotation (i.e., @ParameteredTest), which can enable a test case to run multiple times with different parameters. We provide a usage example here:

image
BhavyaJain711 commented 1 year ago

This is my first open source issue. So please guide me. i'm getting these issues when i run maven test(mvn test) Screenshot (50)

What should i do? Thankyou