Question: I have been tasked with updating the unit testing for my assignment. I have pasted both the code and my test below. Once I added

I have been tasked with updating the unit testing for my assignment. I have pasted both the code and my test below. Once I added the array, my test broke. Not sure where to go from here.

******************** CODE ********************

package libraryapp;

/** * * @author matth */ public class Book {

private String[] author; private int ISBN; private String title; //Constructor public Book(String authors[], int ISBN, String title, int a){ this.author = new String[a]; for(int i=0; 1

************ TEST ************

package libraryapp;

import org.junit.Test; import static org.junit.Assert.*;

/** * * @author matth */ public class BookTest { public BookTest() { }

/** * Test of getAuthor method, of class Book. */ @Test public void testGetAuthor() { System.out.println("getAuthor"); Book instance = new Book("Mickey","Mouse",123); String expResult = "Mouse"; String[] result = instance.getAuthor(); assertEquals(expResult, result); }

/** * Test of getIsbn method, of class Book. */ @Test public void testGetIsbn() { System.out.println("getIsbn"); Book instance = new Book("Mickey","",123); int expResult = 123; int result = instance.getIsbn(); assertEquals(expResult, result); }

/** * Test of getTitle method, of class Book. */ @Test public void testGetTitle() { System.out.println("getTitle"); Book instance = new Book("Mickey","",123); String expResult = "Mickey"; String result = instance.getTitle(); assertEquals(expResult, result); }

/** * Test of setAuthor method, of class Book. */ @Test public void testSetAuthor() { System.out.println("setAuthor"); String author = "Mouse"; Book instance = new Book("Mickey","",123); instance.setAuthor(author); }

/** * Test of setISBN method, of class Book. */ @Test public void testSetISBN() { System.out.println("setISBN"); int ISBN = 0; Book instance = new Book("Mickey","",123); instance.setISBN(ISBN); }

/** * Test of setTitle method, of class Book. */ @Test public void testSetTitle() { System.out.println("setTitle"); String title = "Mickey"; Book instance =new Book("Mickey","",123); instance.setTitle(title); }

/** * Test of validate method, of class Book. */ @Test public void testValidate() { System.out.println("validate"); Book instance = new Book("Mickey","",123); boolean expResult = false; boolean result = instance.validate(); assertEquals(expResult, result); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!