Sei sulla pagina 1di 28

<LIBRARY MANAGEMENT SYSTEM>

Introduction
The Library Management System application for assisting a librarian in managing library books. The system
would provide basic set of features to add/update clients, add/update books, search for books, dues if any and
manage check-in / checkout processes. This test plan is a basic guideline for future testing in the LMS.

Testing Strategies -:
1. Unit Testing:

Definition: Test smallest testable parts of an application, called units, are individually and independently
scrutinized for proper operation.
Participants/ Tested by: Developers
Methodology: Used for the Database test, records in each table, Basic function test, add a student, add a book,
Network test

2. System and Integration Testing.

Definition: Integration testing is the phase in software testing in which individual software modules
are combined and tested as a group.
System integration testing (SIT) is a high-level software testing process in which testers verify that all
related systems maintain data integrity and can operate in coordination with other systems in the same
environment.
Participants/ Tested by: System Tester
Methodology: It is used for the Database test, Queries for insert, update, delete the records.

3. Acceptance Testing -:

Definition: Formal testing with respect to user needs, requirements, and business processes conducted to
determine whether or not a system satisfies Participants/ Tested by: Users / End Users
Methodology: It is used for Whole System Test.

4. Performance and Stress Testing

Definition: Determine how a system performs in terms of responsiveness and stability under a particular
workload.
Stress testing tries to break the system under test by overwhelming its resources or by taking resources away
from it.
Participants/ Tested by: Tester
Methodology: It is used for the Database test, records in each table, Basic function test, Network test.
Index

1. Introduction.
2. Program.
3. Algorithm.
4. Documentation.
5. Flowchart.
6. Test cases
1. Boundary Value analysis
2. Equivalence value analysis.
3. Path testing.
1 .PROGRAM
package com.lms;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
public class LMSImpl
{ static List<BookDetails> books = new ArrayList<BookDetails>();
static Map<Integer, ArrayList<BookIssueDetails>> hm = new HashMap<Integer, ArrayList<BookIssueDetails>>();
public static void main(String[] args) {
addIssueDetails();
System.out.println("Library Management System");
System.out.println("Press 1 to add Book");
System.out.println("Press 2 to issue a book");
System.out.println("Press 3 to return a book");
System.out.println("Press 4 to print the book details");
System.out.println("Press 5 to print complete issue detais");
System.out.println("Press 6 to exit");
Scanner c = new Scanner(System.in);
int choice = c.nextInt();
do
{ switch (choice)
{ case 1:
addBook();
break;

case 2:
issueBook();
break;

case 3:
returnBook();
break;

case 4:
printBookDetails();
break;

case 5:
printCompleteIssueDetails();
break;

case 6:
System.exit(0);
default:
System.out.println("Invalid input");
break;
}
c = new Scanner(System.in);
choice = c.nextInt();}
while (choice > 0 && choice < 6);}
private static void printCompleteIssueDetails()
{ for (Map.Entry<Integer, ArrayList<BookIssueDetails>> entry : hm.entrySet())
{ for (BookIssueDetails b : entry.getValue()) {
System.out.println(entry.getKey() + " " + b.getBookNumber()
+ " " + b.getNsa5a6ame() + " " + b.getNoOfBookIssued()
+ " " + b.getIssueDate() + " " + b.getReturnDate());}}}
private static void printBookDetails() {
for (BookDetails b : books)
{ System.out.print(b.getBookNumber() + " " + b.getBookName() + " "+ b.getCount() + " " + b.getPrice());}}
private static void returnBook()
{ System.out.println("Enter studentId & bookId");
Scanner c = new Scanner(System.in);
int id = c.nextInt();
int bookId = c.nextInt();
List<BookIssueDetails> bd = hm.get(id);
for (BookIssueDetails b : bd) {
if (b.getBookNumber() == bookId)
{ Date issueDate = b.getIssueDate();
Date todayDate = new Date();
long diff = todayDate.getTime() - issueDate.getTime();
long diffDays = diff / (24 * 60 * 60 * 1000);
if (diffDays > 10)
{ int fine = (int) (diffDays - 10);
fine = fine * 10;
System.out.println("Total Fine " + fine + " Rs.");}}}}
private static void addIssueDetails() {
BookIssueDetails bd1 = new BookIssueDetails(1,"abc",1,new Date("04/04/2015"));
BookIssueDetails bd2 = new BookIssueDetails(2,"xyz",1,new Date());
BookIssueDetails bd3 = new BookIssueDetails(3,"mn",1,new Date());
BookIssueDetails bd4 = new BookIssueDetails(4,"u",1,new Date());
ArrayList<BookIssueDetails> list1 = new ArrayList<BookIssueDetails>();
ArrayList<BookIssueDetails> list2 = new ArrayList<BookIssueDetails>();
ArrayList<BookIssueDetails> list3 = new ArrayList<BookIssueDetails>();
Array List<BookIssueDetails> list4 = new Array List<BookIssueDetails> ();
list1.add (bd1);
list2.add (bd2);
list3.add (bd3);
list4.add (bd4);
hm.put (100, list1);
hm.put (101, list2);
hm.put (103, list3);
hm.put (104, list4);
}
Private static void issue Book ()
{ System.out.println ("Enter Student Id, Booknumber, name and price");
Scanner c = new Scanner (System. in);
int student = c.nextInt();
Scanner c1 = new Scanner (System. in);
int book Number = c1.nextInt();
Scanner c2 = new Scanner (System. in);
String name = c2.nextLine ();
Scanner c3 = new Scanner (System. in);
String issue Date = c3.nextLine ();
BookIssueDetails newIssuedBook = new BookIssueDetails ();
newIssuedBook.setName (name);
newIssuedBook.setBookNumer (book Number);
Array List<BookIssueDetails> l=new Array List<BookIssueDetails> ();
SimpleDateFormat formatter = new SimpleDateFormat ("dd-MMM-yyyy");
Try
{ Date date = formatter. Parse(issue Date);
newIssuedBook.setIssueDate (date);}
Catch (Parse Exception e) {e.printStackTrace ();}
List<BookIssueDetails> list = hm.get (student);
For (BookIssueDetails b: list)
{ int value = b.getNoOfBookIssued();
newIssuedBook.setNoOfBookIssued (++value);
l.add (newIssuedBook);
if (value > 2)
System.out.println ("You already issued max(2) books");
Else
hm.put (student, l) ;}}
Private static void add Book ()
{ System.out.println ("Enter Book number, name and price");
Scanner c = new Scanner (System. in);
int book Number = c.nextInt();
String name = c.nextLine ();
Double price = c.nextDouble ();
Book Details book = new Book Details (book Number, name, price);
Books. Add (book); }}

Package com.lms;
Import java.util.Date;
Public class BookIssueDetails {
Private Int book Number;
Private String name;
Private Int totalBookAllowed = 2;
Private Int noOfBookIssued=0;
private Date issueDate;
private Date returnDate;
public BookIssueDetails(int bookNumber,String name,int n,Date issueDate)
{ this.bookNumber=bookNumber;
this.name=name;
this.noOfBookIssued=n;
this.issueDate=issueDate;
}
public BookIssueDetails() {}
public int getBookNumber()
{ return bookNumber; }
public void setBookNumer(int bookNumber)
{ this.book Number = bookNumber; }
public int getNoOfBookIssued()
{ return noOfBookIssued;}
public void setNoOfBookIssued(int noOfBookIssued)
{ this.noOfBookIssued = noOfBookIssued; }
public Date getIssueDate()
{ return issueDate; }
public void setIssueDate(Date issueDate)
{this.issueDate = issueDate; }
public Date getReturnDate()
{ return returnDate; }
public void setReturnDate(Date returnDate)
{ this.returnDate = returnDate; }
public String getName()
{ return name; }
public void setName(String name)
{ this.name = name; }
public int getTotalBookAllowed()
{return totalBookAllowed;}
public void setTotalBookAllowed(int totalBookAllowed)
{this.totalBookAllowed = totalBookAllowed;}}
package com.lms;
public class BookDetails {
private int bookNumber;
private String bookName;
private Double price;
private int count;
public BookDetails(int bookNumber,String name,Double price)
{ this.bookNumber=bookNumber;
this.bookName=name;
this.price=price;
}
public int getCount()
{ return count; }
public void setCount(int count)
{ this.count = count; }
public int getBookNumber()
{return bookNumber; }
public void setBookNumber(int bookNumber)
{this.bookNumber = bookNumber; }
public String getBookName()
{return bookName;}
public void setBookName(String bookName)
{this.bookName = bookName;}
public Double getPrice()
{return price;}
public void setPrice(Double price)
{this.price = price;}}

package com.lms;
public class StudentDetails
{ private int studentId;
private String studentName;
private String className;
public int getStudentId()
{ return studentId;}
public void setStudentId(int studentId)
{ this.studentId = studentId;}
public String getStudentName()
{return studentName;}
public void setStudentName(String studentName)
{ this.studentName =studentName;}
public String getClassName()
{return className;}
public void setClassName(String className)
{this.className = className;}}}
2 .ALGORITHM
Algorithm:
Step1 : start
Step2 : addIssueDetails
Print Library Management System
Print Press 1 to add Book
Print Press 2 to issue a book
Print Press 3 to return a book
Print Press 4 to print the book details
Print Press 5 to print complete issue detais
Print Press 6 to exit
Step3 : do
Step4 : switch choice
case 1: addBook
break
case 2:issueBook
break
case 3:returnBook
break
case 4:printBookDetails
break
case 5:printCompleteIssueDetails
break
case 6:default:
print Invalid input
break
step5 : while choice > 0 && choice < 6
step6 : for BookIssueDetailsb entry.getValue
step7 : printentry.getKeyb.getBookNumber
step8 : b.getNameb.getNoOfBookIssued
step9 : b.getIssueDate b.getReturnDate
step10 : for BookDetails b : books
step11 : printb.getBookNumberb.getBookName
step12 : b.getCountb.getPrice
step13 : print Enter studentId&bookId
step14 : forBookIssueDetailsd
step15 : ifb.getBookNumberbookId
step16 : DateissueDate = b.getIssueDate
step17 : DatetodayDate = new Date
step18 : long diff = todayDate.getTime () - issueDate.getTime ()
step19 : longdiffDays = diff / (24 * 60 * 60 * 1000)
step20 : ifdiffDays> 10
step21 : int fine = (int) (diffDays - 10)
fine = fine * 10;
step22 : println Total Fine “+ fine + “Rs””
step23 : private static void addIssueDetails ()
BookIssueDetails bd1 = new BookIssueDetails (1,"abc", 1, new Date ("04/04/2015"))
BookIssueDetails bd2 = new BookIssueDetails (2,"xyz", 1, new Date ())
BookIssueDetails bd3 = new BookIssueDetails (3,"mn", 1, new Date ())
BookIssueDetails bd4 = new BookIssueDetails (4,"u", 1, new Date ())
Array List<BookIssueDetails> list1 = new Array List<BookIssueDetails>()
Array List<BookIssueDetails> list2 = new Array List<BookIssueDetails>()
Array List<BookIssueDetails> list3 = new Array List<BookIssueDetails>()
Array List<BookIssueDetails> list4 = new Array List<BookIssueDetails>()

list1.add (bd1)
list2.add (bd2)
list3.add (bd3)
list4.add (bd4)
hm.put (100, list1)
hm.put (101, list2)
hm.put (103, list3)
hm.put (104, list4)
step24 : private static void issue Book ()
Print Enter Student Id, Booknumber, name and price
Scanner c = new Scanner (System. in)
IntstudentId = c.nextInt ()
Scanner c1 = new Scanner (System. in)
IntbookNumber = c1.nextInt ()
Scanner c2 = new Scanner (System.in)
String name = c2.nextLine ()
Scanner c3 = new Scanner (System. in)
String issue Date = c3.nextLine ()
BookIssueDetailsnewIssuedBook = new BookIssueDetails ()
newIssuedBook.setName (name)
newIssuedBook.setBookNumer (book Number);

step25 : private static void addBook ()


PrintEnter Book number, name and price
Scanner c = new Scanner (System.in)
IntbookNumber = c.nextInt ()
String name = c.nextLine ()
Double price = c.nextDouble ()

Step26 : Book Details book = new Book Details (book Number, name, price)
Books. Add (book)
step27 : public class Student Details
PrivateintstudentId
Private String student Name
Private String class Name
PublicintgetStudentId ()
ReturnstudentId
step28 : public void setStudentId (intstudentId)
this.studentId = studentId
step29 : public String getStudentName ()
ReturnstudentName
step30 : public void setStudentName (String student Name)
this.studentName = studentName
step31 : public String getClassName ()
returclassName
step32 : public void setClassName (String className)
this.className = className
3. FLOWCHART
Boundary value Test cases for input data
Add books

Case id Description Input data Expected output Actual output Status


01 Enter the Book Book number Message should Book number is Pass
number which is to be display Book number added
added

02 Enter the Book name Book name Message should Book name Pass
display Book name

03 Enter the Book price Book price Message should Book price Pass
display Book price

Issue books

Case id Description Input data Expected output Actual output Status

01 Enter the Student Id Student Id Message should Student Id Pass


display Student Id
02 Enter the Book Book number Message should Book number Pass
number display Book number
03 Enter the Book Book name Message should Book name Pass
name display Book name

04 Enter the Issue Issue date Message should Issue date Pass
date display Issue date
. Book Details

Case id Description Input data Expected Actual Status


output output .
01 Enter the Book number Book number Message should Book number Pass
display Book
number
02 Enter the Book name Book name Message should Book name Pass
display Book name

03 Enter the Book Price Book Price Message should Book Price Pass
display Book Price

04 Enter the number of Book count Message should Book count Pass
books i.e count display Book count

Book Issue Details

Case id Description Input data Expected data Actual output Status


01 Enter the Book Book number Message should Book number Pass
number display Book
number
02 Enter the name of Book name Message should Book name Pass
the Book issued display Book name
03 Enter the Book issue Book issue date Message should Book issue date Pass
date display Book issue
date

04 Enter the Book Book Return date Message should Book Return date Pass
Return date display Book Return
date
.Student details

Case id Description Input data Expected output Actual output Status

01 Enter the Student Id Student Id Message should Student Id Pass


display Student Id
02 Enter the Student Student name Message should Student name Pass
name display Student
name
03 Enter the Student Student class Message should Student class Pass
class display Student
class

Case ID Description Input Data Expected Output Actual Output Status


01 Enter the valid Student ID Message should Student ID PASS
student ID display student ID
02 Enter the invalid Student ID Message should Student ID is invalid PASS
student ID display invalid
student ID
03 Enter the valid book Book number Message should Book number PASS
number display book number
04 Enter the invalid Book number Message should Book number is PASS
book number display invalid book invalid
number
05 Enter the valid book Book name Message should Book name PASS
name display book name
06 Enter the invalid Book name Message should Book name does not PASS
book name display book name match
doesn’t match
07 Enter the valid issue Issue date Message should Issue date PASS
date display issue date
08 Enter the invalid Issue date Message should Issue date is not PASS
issue date display issue date not matching
matching
Equivalence
Stud Case ID Description Input Data Expected Output Actual Output Status
ent 01 Enter valid student ID Student ID Message should Student ID PASS
deta display student ID
ils: 02 Enter invalid student Student ID Message should Student ID not PASS
ID display invalid student matched
ID
03 Enter valid student Student name Message should Student name PASS
name display valid student
name
04 Enter invalid student Student name Message should Student name is not PASS
name display invalid student matched
name
05 Enter valid student Student class Message should Student class PASS
class display valid student
class
06 Enter invalid student Student class Message should Invalid student class PASS
class display invalid student
class
Issue book:
Book issue details:

Case ID Description Input Data Expected Actual Status


Output Output
01 Enter the Book number Message Book number PASS
valid book should
number display book
number
02 Enter the Book number Message Book number PASS
invalid book should is invalid
number display
invalid entry
03 Enter the Book name Message Issued book PASS
name of the should name
issued book display
name issued book
name
04 Enter the Book name Message Issued book PASS
invalid name should name is
of issued display the invalid
book name invalid book
name
05 Enter the Issue date Message Book issue PASS
book issued should date
date display book
issued date
06 Enter the Issue date Message Issued date PASS
invalid book should of the book is
issued date display invalid
invalid entry
07 Enter the Book return Message Return date PASS
book return date should of the book
date display
returning
date of book
08 Enter the Book return Message Book PASS
invalid date should returned
returning display date does
date invalid return not match
date
Case ID Description Input Data Expected Output Actual Output Status
01 Enter the valid Book number Message should Message should PASS
Book details: book number display the display correct
correct book book name
number
02 Enter the invalid Book number Message should Message should PASS
number display does not display does not
match match
03 Enter the valid Book name Message should Message should PASS
book name display book display book
name name
04 Enter the invalid Book name Message should Message should PASS
book name display invalid display invalid
book name book name
05 Enter the valid Book price Message should Message should PASS
book price display book price display book price
06 Enter the invalid Book price Message should Message should PASS
book price display invalid display invalid
input input
Add books: 07 Enter the number Book count Message should Message should PASS
of books i.e., display book display book
count count count
Case ID Description
08 Input
Enter Expected Output
the invalid Book count Actual Status
Message should Message should PASS
Data
number of books Outputdisplay invalid display invalid
01 Enter the Book Message should New book input PASS book count
book number number display new book number is
which is to number successfully
be added successfully added added
02 Enter the Book Message should Book number PASS
book number number display book is is already
which is already added added
already
added
03 Enter the Book Message should Book name PASS
name of the name display book name successfully
book added successfully added
04 Enter the Book Message should Book name is PASS
name of the name display book name already
book present already added added
05 Enter the Book Message should Book price is PASS
price of the price display book price added
book is added successfully
06 Enter the Book Message should Book price is PASS
price already price display the existing existing
exists book price

Potrebbero piacerti anche