Mutation testing is a way to check how good your tests are by making small changes (mutations) to your code and seeing if the tests catch those changes.
Click to reveal answer
beginner
What does PIT stand for in mutation testing?
PIT stands for "PIT" or "Pitest", a popular mutation testing tool for Java that works well with JUnit tests.
Click to reveal answer
intermediate
How does PIT help improve test quality?
PIT changes parts of your code and runs tests to see if tests fail. If tests don't fail, it means tests might miss bugs, so you can improve them.
Click to reveal answer
beginner
What is a 'mutant' in mutation testing?
A mutant is a version of your code with a small change introduced by the mutation testing tool to check if tests detect it.
Click to reveal answer
intermediate
What does it mean if a mutant survives in PIT testing?
If a mutant survives, it means the tests did not catch the change, showing a possible weakness in your test coverage.
Click to reveal answer
What is the main goal of mutation testing?
ATo check if tests can find small code changes
BTo speed up test execution
CTo write new features automatically
DTo remove bugs from production code
✗ Incorrect
Mutation testing checks if your tests can detect small changes (mutations) in the code.
In PIT, what is a 'mutant'?
AA test case
BA bug report
CA changed version of the code
DA test runner
✗ Incorrect
A mutant is a version of your code with a small change introduced to test your tests.
If a mutant survives, what does it mean?
ATests caught the change
BTests ran faster
CCode is error-free
DTests missed the change
✗ Incorrect
A surviving mutant means tests did not detect the change, indicating weak test coverage.
Which tool is commonly used for mutation testing in Java with JUnit?
APIT
BJUnit5
CSelenium
DMockito
✗ Incorrect
PIT is a popular mutation testing tool for Java that works with JUnit.
What should you do if mutation testing shows many surviving mutants?
AIgnore them
BWrite better tests to catch those mutants
CDelete the code
DRun tests less often
✗ Incorrect
Surviving mutants mean tests miss bugs, so improving tests is needed.
Explain how mutation testing with PIT helps improve your test suite.
Think about how changing code and checking tests can show test quality.
You got /4 concepts.
Describe what a 'mutant' is and what it means when it survives mutation testing.
Focus on the mutant concept and test detection.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of mutation testing using PIT in JUnit projects?
easy
A. To check if tests can detect small changes (mutations) in the code
B. To improve the performance of the application
C. To generate new test cases automatically
D. To refactor the code for better readability
Solution
Step 1: Understand mutation testing concept
Mutation testing changes code slightly to see if tests catch the changes.
Step 2: Identify PIT's role in JUnit projects
PIT automates mutation testing to check test effectiveness.
Final Answer:
To check if tests can detect small changes (mutations) in the code -> Option A
Quick Check:
Mutation testing = detect code changes [OK]
Hint: Mutation testing checks test strength by code changes [OK]
Common Mistakes:
Thinking mutation testing improves app speed
Confusing mutation testing with test generation
Assuming mutation testing refactors code
2. Which of the following is the correct way to run PIT mutation testing with Maven in a JUnit project?
easy
A. mvn test:pitest
B. mvn pitest:mutationCoverage
C. mvn mutation:test
D. mvn pit:run
Solution
Step 1: Recall PIT Maven command
The standard Maven command to run PIT is mvn pitest:mutationCoverage.
Step 2: Check other options for correctness
Other options are invalid or do not match PIT's official command syntax.
5. In a JUnit project using PIT, you notice that mutation coverage is low even though your tests pass. What is the BEST way to improve mutation coverage?
hard
A. Ignore mutation coverage and focus on code coverage
B. Increase the number of mutations PIT generates
C. Disable mutation testing for complex classes
D. Add more tests that fail when code is mutated
Solution
Step 1: Understand mutation coverage meaning
Low mutation coverage means tests do not fail when code is changed (mutated).
Step 2: Identify how to improve mutation coverage
Adding tests that detect mutations (fail on changes) improves mutation coverage.
Final Answer:
Add more tests that fail when code is mutated -> Option D