I. Introduction of the topic
It is assumed that there are two kinds of users, librarians and readers in the library management system, and the readers are divided into teacher readers and student readers. All users are logged on to the system before they can use various features. When you log in, you need to provide the user's account and password information. In addition, for different users, after successful login display different welcome information (including the user's name, identity, etc.). Please simulate the login function of the library management system according to the above requirements.
Second, the source of GitHub links
Https://github.com/bbker/library
Third, the design of the module test cases, test results
Package newlibrary;
Import static org.junit.assert.*;
Import Org.junit.After;
Import Org.junit.Before;
Import Org.junit.Test;
public class Testtest {
@Before
public void SetUp () throws Exception {
}
@After
public void TearDown () throws Exception {
}
@Test
public void Test () {
Administration A=new Administration ("Zhang", 123456);
Assertequals (A.name, "Zhang");
Assertequals (A.password, 123456);
Assertequals (a.who (), "Zhang San Administrator");
Student s=new Student ("Wangwu", 333333);
Assertequals (S.name, "Wangwu");
Assertequals (S.password, 333333);
Assertequals (s.who (), "Harry classmate");
Teacher t=new Teacher ("Lisi", 999999);
Assertequals (T.name, "Lisi");
Assertequals (T.password, 999999);
Assertequals (t.who (), "John Doe Teacher");
}
}
Test run:
1. Enter the correct test results
2. Input Error test results
Iv. problems and solutions, experience
The inheritance relationship of this program class:
The user class is the parent class of the reader class, the administration class, and the reader class is the parent class of the teacher class and the student class.
Administration, Reader class inherits the member variable of user, abstract method login ().
The Teacher, student class inherits the member variable of user, overwriting the reader class login, who method.
The first use of unit testing tools, in our team blog Www.cnblogs.com/bbkers published a little about the current mainstream testing unit testing tools, self-teaching through the teacher and online learning has initially mastered a little junit4 knowledge, and applied to this program, The shortcomings are also invited to advise the Netizen.
Personal project-book Management system landing function simulation