Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question
  • Problem: To write the JUnit test cases for our methods, you need to create two test methods:

    1. testLeapYear: This method should test if the isLeapYear method returns true for a given leap year. For example, you can choose the year 2020 and verify if the method returns true for it. If it does, the test will pass. If it doesn't, the test will fail.

    2. testNotLeapYear: This method should test if the isLeapYear method returns false for a given non-leap year. For example, you can choose the year 1900 and verify if the method returns false for it. If it does, the test will pass. If it doesn't, the test will fail.

---------------------------------------------------------------------------------------------------------------------------------------------------------

import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;

public class LeapYearTest {

// Test case to check if a year is a leap year
@Test
public void testLeapYear() {
//create a variable of int type called "year" and assign it with value "2020"

//create a variable of boolean type, call it "expectedResult" and assign it with value "true"

//Call the method isLeapYear() and pass "year" as an argument to it,store the result in a variable of boolean type called "actualResult"

//Verify if the actual result is equal to the expected result using assertTrue()
}

// Test case to check if a year is not a leap year
@Test
public void testNotLeapYear() {

//create a variable of int type,call it "year" and assign it with value "1900"

//create a variable of boolean type, call it "expectedResult" and assign it with value "false"

//Call the method isLeapYear() and pass "year" as an argument to it, store the result in a variable of boolean type called "actualResult"

//Verify if the actual result is equal to the expected result using assertTrue()
}
//Do not modify this code
// Method to check if a year is a leap year or not
private static boolean isLeapYear(int year) {
// Check if the year is divisible by 400 or divisible by 4 and not divisible by 100
return year % 400 == 0 || (year % 4 == 0 && year % 100 != 0);
}

}
Expert Solution
Check Mark
Still need help?
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

Code is not working for me. I used the same code but i keep getting error

Solution
Bartleby Expert
by Bartleby Expert
SEE SOLUTION
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

Code is not working for me. I used the same code but i keep getting error

Solution
Bartleby Expert
by Bartleby Expert
SEE SOLUTION
Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
    SEE MORE QUESTIONS
    Recommended textbooks for you
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education