What would now be your next step to proceed as efficient as possible, to validate the correctness of the class above?
A developer has implemented a class that calculates if a given date is a leap year.
The definition for the leap year is given:
Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100, but these centurial years are leap years if they are exactly divisible by 400.
– divisible by 4
– but not by 100
– years divisible by 400 are leap anyway
You have already thought about it and started with the first test class; the test class looks like (pseudo JavaScript used here):
// LeapYear.spec.js
describe(‘Leap year calculator’, () => {
it(‘should consider 1996 as leap’, () => {
expect(LeapYear.isLeap(1996)).toBe(true);
});
});
What would now be your next step to proceed as efficient as possible, to validate the correctness of the class above?
A . First write additional test classes to test also other relevant aspects of the leap year calculation
B . First write code that covers other relevant aspects of the leap year calculation
C . First write code that makes this test case fail
D . First write code that makes this test case pass
Answer: D
Explanation:
In the context of test-driven development (TDD), the next step after writing a failing test is to write the minimum amount of code necessary to make the test pass. This approach encourages simple designs and inspires confidence that the system is functioning as expected. Once the test passes, you can then refactor the code to improve its structure without changing its behavior.
Reference: = The ISTQB Advanced Level Agile Technical Tester syllabus outlines the TDD process as a cycle of writing a failing test, making it pass, and then refactoring the code. This is a fundamental practice in Agile technical testing to ensure that the codebase remains clean and maintainable12.
Latest CTAL-ATT Dumps Valid Version with 40 Q&As
Latest And Valid Q&A | Instant Download | Once Fail, Full Refund