Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 15

CSH405B-P SOFTWARE TESTING WORKSHOP

DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY

Software Testing – ASSIGNMENT


Course Outcomes:
CSH405B.4: Utilize the learnt principles and techniques of software testing to evolve further.

Bloom's Taxonomy: BT1, BT2, BT3, BT4


In context of ASSIGNMENT as a part of your curriculum, you need to implement
the following:

For the chosen small project designed in java, implemented as mini-project-1, design
and implement Junit Tests for the mini-project-1 java source code modules.

NAME – Nikhil Yadav

ROLL No.-2K19CSUN01039
CSH405B-P SOFTWARE TESTING WORKSHOP

STUDENT MANAGEMENT SYSTEM

Student Management System is software which is helpful for students as well


as the school authorities. In the current system all the activities are done
manually. It is very time consuming and costly. Our Student Management
System deals with the various activities related to the students.

In the software we can register as a user and user has of two types, student
and administrator. Administrator has the power to add new user and can edit
and delete a user. A student can register as user and can add edit and delete
his profile. The administrator can add edit and delete marks for the student.
All the users can see the marks.
CSH405B-P SOFTWARE TESTING WORKSHOP

JAVA CODE

package studentdatabaseapp;

import java.util.Scanner;

public class Student {


private String firstName;
private String lastName;
private int gradeYear;
private String studentID;
private String courses = "";
private int tuitionBalance = 0;
private int costofCourse = 600;
private static int id = 1000;

//Constructor: prompt user to enter student's name and


year
public Student() {
Scanner in = new Scanner(System.in);
System.out.print("Enter student first name:
"); this.firstName = in.nextLine();
CSH405B-P SOFTWARE TESTING WORKSHOP

System.out.print("Enter student last name:


"); this.lastName = in.nextLine();

System.out.print("1 - Freshman\n2 - for


Sophmore\n3 - Junior\n4 - Senior\nEnter student class
level: ");
this.gradeYear = in.nextInt();

setStudentID();

//Generate an id

private void setStudentID() {


//Grade Level + ID
id++;
this.studentID = gradeYear + "" + id;
CSH405B-P SOFTWARE TESTING WORKSHOP

Enroll in courses
public void enroll() {

//Get Inside a loop, user hits


0 do {
System.out.print("Enter a course to enroll (Q to
quit): ");
Scanner in = new Scanner(System.in);
String course = in.nextLine();
if (!course.equals("Q")) {
courses = courses + "\n " + course;
tuitionBalance = tuitionBalance +
costofCourse;

}
else {

break;
}
} while (1 != 0);
CSH405B-P SOFTWARE TESTING WORKSHOP

}
//View Balance
public void viewBalance() {
System.out.println("Your Balance is: $"
+ tuitionBalance);

//Pay Tuition
public void payTuition() {
viewBalance();
System.out.println("Enter your payment: $");

Scanner in = new Scanner(System.in);


int payment = in.nextInt();
tuitionBalance = tuitionBalance - payment;
System.out.println("Thank you for your payment
of $" + payment);
viewBalance();
}

// Show Status
CSH405B-P SOFTWARE TESTING WORKSHOP

public String toString() {


return "Name: " + firstName + " " + lastName
+ "\nGrade Level: " + gradeYear + "\
nStudent ID: " + studentID + "\
nCourses Enrolled:" + courses + "\
nBalance: $" + tuitionBalance;
}
}

OUTPUT SNAPSHOTS:
CSH405B-P SOFTWARE TESTING WORKSHOP
CSH405B-P SOFTWARE TESTING WORKSHOP

ASSIGNMENT SOLUTION IMPLEMENTED

TEST CASES:

package studentdatabaseapp;

import static org.junit.Assert.*;

import org.junit.Test;

public class sumunit {


unittestingclass obj= new unittestingclass();

@Test
public void testSum()
{ assertEquals(100,obj.sum(10,
15));
}

}
CSH405B-P SOFTWARE TESTING WORKSHOP

package studentdatabaseapp;

import static org.junit.Assert.*;

import org.junit.Test;

public class squareunit {

@Test
public void test() {
unittestingclass obj1 = new
unittestingclass(); int output_f =
obj1.sqaure(4); //Test the output
assertEquals(16,output_f);
}

}
CSH405B-P SOFTWARE TESTING WORKSHOP

package studentdatabaseapp;

import static org.junit.Assert.*;

import org.junit.Test;

public class negative {

unittestingclass obj= new unittestingclass();

@Test
public void testSum()
{ assertEquals(3,obj.sum(-5,
8));
}

}
CSH405B-P SOFTWARE TESTING WORKSHOP

package studentdatabaseapp;

import static org.junit.Assert.*;

import org.junit.Test;

public class bothnegtive {

unittestingclass obj= new unittestingclass();

@Test
public void testSum()
{ assertEquals(3,obj.sum(-10, -
15));
}

}
CSH405B-P SOFTWARE TESTING WORKSHOP

SNAPSHOTS
CSH405B-P SOFTWARE TESTING WORKSHOP
CSH405B-P SOFTWARE TESTING WORKSHOP

You might also like