Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Asm2 1ST Apdp Truongnn BH00704

Download as pdf or txt
Download as pdf or txt
You are on page 1of 37

ASSIGNMENT 2 FRONT SHEET

Qualification Pearson BTEC Level 5 Higher National Diploma in Computing

Unit number and title Unit 20: Applied Programming and Design Principles

Submission date Date Received 1st submission

Re-submission Date Date Received 2nd submission

Student names & codes Final scores Signatures

1.Cù Đăng Trường Giang-BH00686

Group number: 2. Lưu Quang Triệu-BH00678

3. Nguyễn Hữu Lâm-BH00572

4. Nguyễn Nam Trường-BH704

Class IT0603 Assessor name Bình DQ

Student declaration
I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that making a
false declaration is a form of malpractice.
Grading grid

P5 M3 P6 P7 M4 D2
OBSERVATION RECORD

Student 1 Lưu Quang Triệu

Description of activity undertaken

I work on courses and timetables with the following functions:

-display the timetable for students and teachers to see

-create login page

-Responsible for quality assurance and testing of the SIMS application.

Assessment & grading criteria

How the activity meets the requirements of the criteria

Student
Date:
signature:

Assessor
Date:
signature:

Assessor
name:
Student 2 Cù Đăng Trường Giang

Description of activity undertaken

I am working on a studentcontroller that has the following functions:

-Can view course information

-Can view schedule information

-can see scores

-Responsible for quality assurance and testing of the SIMS application.

Assessment & grading criteria

How the activity meets the requirements of the criteria

Student
Date:
signature:

Assessor
Date:
signature:

Assessor
name:
Student 3 Nguyễn Hữu Lâm

Description of activity undertaken

homeadmincontroller which has the following functions: -Add, edit, delete member information

-Add, edit, delete student information

-Can edit timetable

-Can edit course information

-Responsible for quality assurance and testing of the SIMS application

Assessment & grading criteria

How the activity meets the requirements of the criteria

Student
Date:
signature:

Assessor
Date:
signature:

Assessor
name:
Student 4 Nguyễn Nam Trường

Description of activity undertaken

-Can view course information

-Can view schedule information

-can see scores

-Can add students and grade students

-Responsible for quality assurance and testing of the SIMS application.

Assessment & grading criteria

How the activity meets the requirements of the criteria

Student
Date:
signature:

Assessor
Date:
signature:

Assessor
name:
r Summative Feedback: r Resubmission Feedback:

Grade: Assessor Signature: Date:


Internal Verifier’s Comments:

Signature & Date:


Table of Contents
A. Introduce ................................................................................................................................................................................................................................. 9
B. Content .................................................................................................................................................................................................................................. 10
I. Activity 1. Examine and discussion different test methods of implementing automatic testing can be done for the SIMS application ................... 10
1. What is Unit Test? ........................................................................................................................................................................................................ 10
1. Integration Testing ....................................................................................................................................................................................................... 11
2. What is Functional Testing?......................................................................................................................................................................................... 13
3. End-to-end Testing ....................................................................................................................................................................................................... 15
4. Unit Testing exammple: ............................................................................................................................................................................................... 16
II. Activity 2 Build a data processing application with automating testing based on a developed design ............................................................................ 18
1. Student Information Management System (SIMS) ......................................................................................................................................................... 18
2. Automatic testing of the developed application in SIMS ............................................................................................................................................... 29
Conclution...................................................................................................................................................................................................................................... 36
Reference ....................................................................................................................................................................................................................................... 37
Table of Figrue
Figure 1: Unit Test .......................................................................................................................................................................................................................... 10
Figure 2: Integration Testing .......................................................................................................................................................................................................... 12
Figure 3:Functional Test ................................................................................................................................................................................................................. 14
Figure 4:End to End ........................................................................................................................................................................................................................ 15
Figure 5:Login form ........................................................................................................................................................................................................................ 19
Figure 6: Admin Dashboard ........................................................................................................................................................................................................... 20
Figure 7:Add New Student function and Edit Function ................................................................................................................................................................. 21
Figure 8: When Add and Edit Succesfull ........................................................................................................................................................................................ 21
Figure 9: Code for Add Student function ....................................................................................................................................................................................... 22
Figure 10: Code for Edit and Delete function ................................................................................................................................................................................ 23
Figure 11: Add and Ediit sucessfull ................................................................................................................................................................................................ 24
Figure 12:Add Teacher and Edit ..................................................................................................................................................................................................... 24
Figure 13:Add and Edit Course....................................................................................................................................................................................................... 25
Figure 14: Sucessfull Add and Edit Course ..................................................................................................................................................................................... 25
Figure 15: Student Dashboar ......................................................................................................................................................................................................... 26
Figure 16: Student Timetable ........................................................................................................................................................................................................ 27
Figure 17:Student Course .............................................................................................................................................................................................................. 27
Figure 18: XUnit Framwork ............................................................................................................................................................................................................ 29
A. Introduce

In the ever-evolving landscape of higher education, universities are continuously seeking ways to enhancetheir operational efficiency and
adapt to modern technological standards. Recognizing the pivotal role of a well-structured Student Information Management System (SIMS)
in fostering effective academic administration, our university is embarking on a journey to modernize and elevate its existing SIMS. The aim
is to not only streamline administrative processes but also to embrace contemporary software engineering principles for improved
maintainability and scalability.

To spearhead this transformative initiative, our university has assembled a dynamic team of skilled individuals, and we are honored to be
entrusted with the responsibility of implementing the next- generation SIMS. This project will be characterized by a commitment to Object-
Oriented Principles, adherence to SOLID principles, dedication to clean coding practices, and the incorporation of well- established design
patterns.

Through this undertaking, our goal is to contribute to the academic success of our university and set a benchmark for modern, efficient, and
user-centric student information systems. The journey begins with a robust analysis of user requirements and a thoughtful system design, setting
the foundation for a transformative project that will shape the future of our academic administration.
B. Content
I. Activity 1. Examine and discussion different test methods of implementing automatic testing can be done for the SIMS application
1. What is Unit Test?
As the name implies, unit testing entails testing each 'unit' or 'individual component' of a software application. It is the first and most
common phase in software testing. Unit testing is performed by developers during the application's development phase since it demands
in-depth understanding of the internal architecture and programming. These tests can be automated and repeated periodically as needed.
It is done to ensure that the code is valid and follows logic. It enables developers to uncover issuesin the early stages of constructing the
program, enhancing confidence in the code (SearchSoftwareQuality.(n.d.).

Figure 1: Unit Test


In this test method:

• [Fact] attribute indicates that this method is a test case that should be executed by the xUnit testrunner.
• “StringCalculator” Initialization: An instance of “StringCalculator” is created, representing the classunder test.
• MAXIMUM_RESULT Constant: A string constant is defined with the value "1001", likelyrepresenting the input that will cause an
overflow condition.
• Action Definition: An action is defined to execute the Add method of the “StringCalculator”
▪ instance, passing in MAXIMUM_RESULT as the argument.
• Assertion: The test asserts that invoking the action should throw an “OverflowException,” which isthe expected behavior when the
result exceeds a certain threshold.

This test ensures that the Add method of the “StringCalculator” class correctly throws an “OverflowException” when the result
exceeds a certain threshold, as specified by the test case.

1. Integration Testing
Integration Testing is a type of testing in which software modules are logically integrated and tested in groups.

A typical software project consists of many modules, coded by programmers. Integration testing is testing the compatibility between those
modules.( SearchSoftwareQuality. (n.d.).

Therefore, integration testing is also known as I&T (Integration and Testing), String Testing and sometimes Thread Testing.
Figure 2: Integration Testing

Why is Integration Testing necessary?

Although each module has been Unit Tested, errors still exist for a number of reasons such as:

• Because each module is designed by an independent developer with different knowledge and programming logic, errors may arise when
integrating modules together.
• Customers will change design requirements during the module development process (adding requirements, updating requirements when
found unreasonable...) and these new requirements may not be subject to Unit Testing or integration. error.
• The interfaces of software modules with the database may not be compatible.
• When integrating modules into the system, they may not be compatible with the general configuration of the system.
• Incomplete handling of exceptions can cause errors.

Example of Integration Testing:

Suppose you work for an IT organization that has been asked to develop an online shopping website for Camp World, a company that sells
camping equipment. Once requirements gathering, analysis and design were complete, a developer was assigned to develop each module below.

• User Registration and Authentication/Login


• Product portfolio
• Cart
• Pay
• Payment gateway integration
• Track shipping and packages

Once each module is assigned to a developer, the developer begins coding functionality on their individual machines. They deployed the
respective modules on their machines to see what worked and what didn't, when they started module development. After they completed
development, the developers tested their individual functions as part of their unit testing and found a number of defects. They have corrected
these defects. At this point, they feel their modules are complete. Integration testing should be performed to confirm that all modules work
together. When they deployed all their code in a common machine, they found that the application did not work as expected because the
individual modules did not work well together. There were some errors like - after logging in, the user's cart did not show the items they had
previously added, the invoice amount did not include shipping costs, etc.

In this way, Integration Testing helps us identify and fix problems and ensure that the entire application works as expected. (Ngan, 2019)

2. What is Functional Testing?


Functional Testing is one of the quality assurance processes in the field of software testing. In addition, Functional Testing is also known as black
box testing because the source code of the application is not considered during testing. Functions will be tested through entering input values
and evaluating output results without being affected by the internal structure or settings of the application.
The purpose of Functional Testing is to test each function of the application. Thereby it is possible to check whether the previously proposed
functional requirements are met or not. Thanks to Functional Testing, you can avoid redundant testing of unnecessary functionality. At the same
time, it helps prevent multiple errors from appearing at the same time. (SearchSoftwareQuality. (n.d.).

Figure 3:Functional Test

What is the reason to perform Integration Testing?

Each module will be unit tested for the following reasons:

Each Module is designed by programmers who have the ability to program logic thanks to their understanding and differences from other
programmers. Performing integration testing will ensure certain integrity of the software.

Even at the time you develop modules, they can still change within the customer's own spec and these changes often cannot be tested in the
previous unit testing stages.
The interfaces as well as the database of the modules have been determined to be incomplete if combined together.

If system integration of modules is performed, they are often not compatible with the general configuration of the system.

Lack of exception handling is possible.

3. End-to-end Testing
In the long term, End-to-End (E2E) testing refers to a comprehensive software testing approach aimed at evaluating the entire system's
functionality, behavior, and performance from the user's perspective. It involves testing the application's various components, modules,
and subsystems as an integrated whole to ensure that they function seamlessly together and meet the specified requirements.
E2E testing simulates real-world user scenarios, interactions, and workflows, typically spanning multiple layers of the application stack,
including the user interface, business logic, data persistence, and external integrations. Unlike unit testing or integration testing, which
focus on individual units or component interactions, E2E testing evaluates the application's end-to-end flow, covering all the steps a user
might take to accomplish a task or achieve a goal within the system. (SearchSoftwareQuality. (n.d.).

Figure 4:End to End


4. Unit Testing exammple:
XUnit is a popular framework used for writing and running unit tests in .NET applications. It provides a simple and powerful way to organize,
execute, and validate test cases to ensure the accuracy and reliability of source code.

Built on the principles of "design by contract," xUnit focuses on using assertions to check the results of code snippets, determining whether they
function as expected. It supports programming styles such as Test-Driven Development (TDD) and Behavior-Driven Development (BDD), helping
to create quality, maintainable source code. (Stack Overflow. (n.d.)

Some features of xUnit include:

Facts:

• Fact is an attribute used to mark a method as a test method that represents a single, atomic test case.
• Test methods marked with Fact do not take any input parameters and are intended to be used for scenarios where the test case does
not vary based on input data.
• Each method marked with Fact represents a distinct test case and is executed independently.
• Fact is suitable for scenarios where the test case has a fixed input and output, and the test method needs to be executed exactly once
during the test run.

For example,
Assertions:

Assertions are statements in code that verify whether an expected condition or result is true during runtime. In the context of testing, assertions
are used to validate the behavior and outcomes of the code being tested. If an assertion fails during execution, it indicates that the tested
condition or result does not meet the expected criteria, signaling a potential issue or defect in the code. (Literary Devices. (2015)

Assertions typically consist of a condition to be tested and an accompanying message or description to provide context and clarity about the
expectation. When the condition evaluates to false, the assertion fails, and an error or failure message is generated, indicating that the test case
did not pass as expected.

Explanation of the unit tests: Student_AddGrade_CalculatesCorrectGPA:

• We create a “Student” instance and add two grades (3.5 and 4.0) to it.
• We assert that the calculated GPA matches the expected value (3.75).

Student_GradeOutOfRange_ThrowsException:

• We create a “Student” instance.


• We attempt to add a grade that is out of range (e.g., greater than 5.0).
• We assert that adding such a grade should throw an ArgumentException.
By running these unit tests, XUnit will execute each test method and report whether they pass or fail. These tests help ensure that the “Student”
class behaves correctly and handles edge cases appropriately.

II. Activity 2 Build a data processing application with automating testing based on a developed design
1. Student Information Management System (SIMS)
Purpose of SIMS

The Student Information Management System (SIMS) serves as a comprehensive tool for educational institutions to streamline their
administrative tasks, enhance communication channels, and effectively manage student data. At its core, SIMS is designed to simplify the
complexities associated with managing student information, thereby facilitating smoother operations within educational settings.

The primary purpose of SIMS is to centralize and organize various aspects of student data management. It allows schools and educational
institutions to efficiently collect, store, update, and retrieve student information, ranging from basic personal details to academic records,
attendance records, disciplinary actions, and more. By providing a centralized database for student information, SIMS enables administrators
and educators to access accurate and up-to-date information whenever needed, thereby reducing the time and effort required for administrative
tasks.
Login Function

In a Student Information Management System (SIMS), the login function plays a crucial role in verifying the identity of users and granting
access to the system's features and services. When users access the SIMS application, they encounter the login screen where they need to
provide valid login information, including their email address and previously registered password.

Figure 5:Login form


a) Admin Role
pon logging in with the role of "Admin," users are greeted with the Admin Dashboard, which offers a comprehensive array of
administrative functions tailored to their privileged status within the Student Information Management System (SIMS). As an
administrator, you wield the authority to execute pivotal actions, such as adding new students, appointing teachers, and introducing new
courses, thus ensuring the seamless management and organization of academic endeavors. Let's delve into the functionalities that the
Admin Dashboard bestows upon you:

Figure 6: Admin Dashboard

b) Add New Student:


With a few clicks, you can effortlessly integrate new students into the system, meticulously recording their vital information, including personal
details, academic pursuits, and enrollment status. This function empowers you to expand the student body dynamically, facilitating the growth
and diversity of the educational community.
Figure 7:Add New Student function and Edit Function

Figure 8: When Add and Edit Succesfull


The NewStudent function in the controller is used to handle the addition of a new user, in this case a student, to the system. Here is a detailed
explanation of the steps in this function:

• Read the list of users from the JSON file: First, the function reads the existing list of users from the JSON file named "users.json". This
list contains information about all users in the system, including both students and teachers.
• Generate an ID for the new user: After reading the list of users, the system determines a new ID for the user about to be added. The
approach here is to find the largest ID in the current list and increment it by 1 to ensure the uniqueness of the ID for the new user.
• Assign ID and default role to the new user: After determining the new ID, the system assigns this ID to the new user being added. The
default role for the new user may be a student.
• Add the new user to the list: The new user is then added to the current list of users.
• Update the list of users in the JSON file: After adding the new user to the list, the system updates the JSON file "users.json" with this
new list of users.

Figure 9: Code for Add Student function


Figure 10: Code for Edit and Delete function
c) Add New Teacher
As an administrator, you possess the prerogative to enlist esteemed educators into the SIMS ecosystem, enshrining their expertise within the
academic framework. By adding new teachers, you bolster the faculty roster, enriching the learning experience and fostering a culture of
excellence in instruction.

Figure 12:Add Teacher and Edit

Figure 11: Add and Ediit sucessfull


d) Add New Course

Figure 13:Add and Edit Course

Figure 14: Sucessfull Add and Edit Course


e) Student Role

Figure 15: Student Dashboar

As a student, you have the privilege to access and manage your enrolled courses, allowing you to view the courses you are currently
registered for and select additional courses to enroll in based on your academic interests and requirements. Additionally, you have the
opportunity to access your personalized timetable, providing you with a comprehensive schedule of your classes and academic
commitments. This functionality empowers you to effectively plan and organize your academic pursuits, ensuring you stay on track with
your educational goals.
Figure 17:Student Course

Figure 16: Student Timetable


f) Teacher Role
As teachers role, you can see and edit your student mark
2. Automatic testing of the developed application in SIMS
Understanding SIMS and xUnit

SIMS (Student Information Management System):

While there isn't a universally standardized SIMS, it's typically a software application used in schools to manage student data, attendance, grades,
and other administrative tasks. The specific functionalities and structure of your SIMS will depend on the vendor or custom development.

xUnit Framework:

A popular, free, and open-source testing framework for .NET development. It provides a clean syntax for writing unit tests, assertions for
verifying expected behavior, and features like parameterized tests and mocking for efficient testing. (Stack Overflow. (n.d.).

Figure 18: XUnit Framwork


a) Admin Function Test
Test 1: Delete_ReturnsViewResult_WithUserList

• This test checks what happens when the Index method of the HomeAdminController is called with specific arguments ("TestUser",
"Admin").
• It assumes the Index method is responsible for displaying a list of users.
• The assertions verify the following:
• The returned result is a ViewResult. This indicates the controller is returning a view (a webpage template) to be displayed.
• The model property of the ViewResult is assignable to a List<User>. This means the view is expecting a list of user objects as its data.
• The model list is not null, ensuring data is passed to the view.

Test 2: Edit_ReturnsNotFound_WhenUserNotFound

• This test checks what happens when the Edit method of the HomeAdminController is called with an invalid user ID (999 in this case).
• It assumes the Edit method is responsible for editing a specific user.
• The assertion verifies that the returned result is a NotFoundResult. This indicates the controller could not find the requested user with
the provided ID.

Test 3: NewStudent_ReturnsRedirectToActionResult_WhenModelStateIsValid

• This test checks what happens when the NewStudent method of the HomeAdminController is called with a new user object with specific
properties (Name: "Test User", Role: "Student").
• It assumes the NewStudent method is responsible for creating a new student user.
• The assertions verify the following:
• The returned result is a RedirectToActionResult. This indicates the controller is redirecting to another action after successful user
creation.
• The redirect action name is "Index", suggesting it redirects back to the user list view.

b) Student Function Test


Test: Detail_ReturnsViewResult_WithStudent

This test is likely verifying the behavior of the Detail method within the StudentController.

Arrange:

• A new instance of StudentController is created.


• An existingStudentId variable is set to 1, assuming there's a student with that ID in the system (possibly stored in a data source like
"data.json").

Act:

• The Detail method of the controller is called with the existingStudentId (1). This simulates requesting student details for ID 1.
• The result is stored in a variable named result.

Assert:

• The first assertion (Assert.IsType<ViewResult>(result)) checks if the result is of type ViewResult. This verifies the controller returns a view
(a webpage template) to display details.
• The second assertion (Assert.IsAssignableFrom<Student>(viewResult.ViewData.Model)) uses a more relaxed matching approach. It
checks if the model property of the ViewResult can be assigned to a Student object. This ensures the view expects a student object as its
data.
• The third assertion (Assert.NotNull(model)) confirms that the model property of the ViewResult is not null. This guarantees some student
data is passed to the view.
c) Teacher Function Test
Test 1: Edit_ReturnsNotFound_WhenUserNotFound

This test is similar to the previous ones we saw. It checks the behavior when the Edit method receives an invalid user ID:

Arranges:

• Creates a new instance of TeacherController.


• Sets invalidId to 999, assuming this ID doesn't exist in the system.

Acts:

• Calls the Edit method of the controller with the invalidId.

Asserts:

• Verifies the returned result is a NotFoundResult. This confirms the controller couldn't find a teacher with the provided ID.

Test 2: Edit_UpdatesUserCoreAndStatus_WhenUserExists

This test is more comprehensive and explores a successful edit scenario:

Arranges:

• Creates a new instance of TeacherController.


• Creates a new User object (existingUser) with an ID of 1 and sets a new status ("New Status"). This simulates an existing teacher with an
updated status.

Acts:

• Calls the Edit method of the controller with the existingUser object.

Asserts:

• Verifies the returned result is a RedirectToActionResult. This indicates successful editing and redirection potentially back to a teacher list
view
C. Conclution
In conclusion, our university's commitment to enhancing operational efficiency and embracing modern technological standards through the
modernization of our Student Information Management System (SIMS) reflects our dedication to fostering academic excellence. By assembling
a dynamic team and adhering to Object-Oriented Principles, SOLID principles, and clean coding practices, we are poised to implement a next-
generation SIMS that not only streamlines administrative processes but also sets a benchmark for user-centric student information systems.

Through rigorous analysis of user requirements and meticulous system design, we lay the groundwork for a transformative project that will
shape the future of our academic administration. As we embark on this journey, we are driven by the vision of contributing to the academic
success of our university and creating a model for modern, efficient, and adaptable student information systems. Together, we stand ready to
embrace the challenges and opportunities that lie ahead, confident in our ability to pioneer positive change in higher education.
D. Reference
SearchSoftwareQuality. (n.d.). What is Automated Testing and How Does it Work? [online] Available at:
https://www.techtarget.com/searchsoftwarequality/definition/automated-software-testing [Accessed16 Mar. 2022].

Stack Overflow. (n.d.). What’s an xUnit runsettings equivalent? [online] Available at: https://stackoverflow.com/questions/38458979/whats-an-
xunit-runsettings-equivalent [Accessed 23Mar. 2024].

You might also like