samedi 2 mai 2015

assertequal for method of object type

I am trying to make a test method using Junit test case for GetTeextBook() in course class. notice that GetTeextBook() is type of Textbook object but I always get a failure when I run the courseTest1 class in the method testGetTextBook()

any suggestion?


public class CourseTestCase1 {

private Course course=new Course(101, "Software Engineering");

@Test
public void testGetTextBook() {
Textbook testbook=new Textbook(700, "Data Base System", "Ramez ELmasri",2011);

    assertEquals(testbook,course.getTextbook());
}
@Test
public void testGetCourseCode() {
    assertEquals(101,course.getCourseCode());

         }

@Test
public void testGetName() {
    assertEquals("Software Engineering",course.getName());
}

@Test
public void testToString() {
    testGetCourseCode();
    testGetName();


}

 }





   public class Course {

private int courseCode;
private String courseName;
private Textbook textbook;

private Semester semestr;



public Course() {

this.courseCode = 0;
    this.courseName = null;

    this.semestr = null;
    this.textbook = null;
}

public Course(int courseCode, String courseName) {
    this.courseCode = courseCode;
    this.courseName = courseName;

    semestr = null;
    textbook = null;
}

public Textbook getTextbook() {
    return textbook;
}}}





        public class Textbook {
private int isbn;
private String title, authors;
private int publicationYear;




private TextbookCopy tbcopy;

public Textbook() {
    isbn = 0;
    title = null;
    authors = null;
    publicationYear = 0;



}

public Textbook(int isbn, String title, String authors, int            publicationYear) {
    this.isbn = isbn;
    this.title = title;
    this.authors = authors;
    this.publicationYear = publicationYear;



}

public Textbook(int isbn, String title, String authors,
        int publicationYear, String publisher, String distributor,
        double purchasePrice) {
    this.isbn = isbn;
    this.title = title;
    this.authors = authors;
    this.publicationYear = publicationYear;

}

public String getTitle() {
    return title;
}

public int getPublicationYear() {
    return publicationYear;
}

public String getAuthors() {
    return authors;
}



public Textbook getBook() {
    return this;
}




public int getISBN() {
    return isbn;
}

public String getCopy() {
    return Integer.toString(tbcopy.numbersOfCopy);
}

public void USwoltextbook(int isbn) {

}

public void assignNewBook() {

}

public Textbook createNewTextBook(String info) {
    return null;
}
   }   

Aucun commentaire:

Enregistrer un commentaire