0% found this document useful (0 votes)
4 views4 pages

Testing

The document outlines the aim and purpose of testing a software system, emphasizing the importance of validating functionality, detecting defects, and ensuring reliability. It details the use of the JUnit framework for testing Java applications, including installation instructions and example test implementations. The results indicate that the software has been tested for all scenarios identified in the use case diagram.

Uploaded by

sharmila210604
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Testing

The document outlines the aim and purpose of testing a software system, emphasizing the importance of validating functionality, detecting defects, and ensuring reliability. It details the use of the JUnit framework for testing Java applications, including installation instructions and example test implementations. The results indicate that the software has been tested for all scenarios identified in the use case diagram.

Uploaded by

sharmila210604
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

EXP.

NO: 8
DATE: TESTING THE SOFTWARE SYSTEM

Aim:
To test the software system for all the scenarios identified as per the use case diagram.

Testing:
Testing is a critical phase in the software development lifecycle, aimed at ensuring that a
software application or system performs as expected and meets its requirements. It involves
systematically identifying, detecting, and resolving defects or inconsistencies in the code. By
doing so, testing helps improve the quality, reliability, and performance of the software,
ensuring it aligns with user expectations and business goals.

Purpose of Testing:
The primary purpose of testing is to:
1. Validate functionality: Ensure that the software meets its functional and non-
functional requirements.
2. Detect defects: Identify errors, bugs, or unexpected behaviours in the code.
3. Ensure reliability: Verify that the software performs consistently under various
conditions.
4. Improve performance: Test the software to optimize its speed, scalability, and
responsiveness.
5. Enhance user satisfaction: Ensure the software is user-friendly, secure, and aligned
with end-user needs.

JUnit Framework:
JUnit is a widely-used testing framework for Java, primarily designed for unit testing Java
applications. It is part of the xUnit family of testing frameworks and provides a simple and
effective way to write and execute tests. Key features of JUnit include:
• Annotation-Based Testing: Annotations like @Test, @BeforeEach, and
@AfterEach manage test lifecycles.
• IDE Integration: Compatible with IntelliJ IDEA, Eclipse, and NetBeans for
easy test execution.
• Assertions: Provides methods like assertEquals, assertTrue, and assertThrows for
result validation.
• Parameterized Tests: Allows running tests with different input values for broader
coverage.
• Integration with Build Tools: Works seamlessly with Maven and Gradle for
automated testing.
• Exception Testing: Verifies expected exceptions using assertThrows. Support for
Node.js and browser environments.
• Support for Mocking Frameworks: Works seamlessly with mocking libraries like
Mockito for creating mock objects and isolating dependencies.

Installation:
1. Add JUnit Dependency (Maven): Include the following dependency in your
pom.xml:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.0</version>
<scope>test</scope>
</dependency>
2. Configure Test Plugin (Maven): Ensure the Maven Surefire plugin is configured to
run tests:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.1</version>
</plugin>
</plugins>
</build>
3. Run Tests: mvn test

Testing for our system:


Below is the implementation for testing:
// DAOTests.java
package com.inventory.dao;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class DAOTests {
@Test
public void testAddProduct() {
DAO dao = new DAO(); // Assuming you have a DAO class with methods like
addProduct
Product product = new Product("SampleProduct", 100);
dao.addProduct(product); // Adding a product using DAO class
assertTrue(dao.productExists("SampleProduct")); }
@Test
public void testRemoveProduct() {
DAO dao = new DAO();
Product product = new Product("RemoveProduct", 50);
dao.addProduct(product);
dao.removeProduct("RemoveProduct"); // Removing a product using DAO
assertFalse(dao.productExists("RemoveProduct")); }}

// DTOTests.java
package com.inventory.dto;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class DTOTests {
@Test
public void testDTOValidation() {
SupplierDTO dto = new SupplierDTO("ValidSupplier", 1000);
assertTrue(dto.isValid(), "DTO should be valid"); }

@Test
public void testInvalidDTO() {
ProductDTO dto = new ProductDTO("InvalidProduct", -10); // Invalid price
assertFalse(dto.isValid(), "DTO should not be valid with negative price"); }}
Description Allotted Marks Obtained Marks

Preparation 20

Design/Implementation 20

Viva 15
Output 10
Record 10

Total 75

RESULT:
Thus, the software is tested for all the scenarios identified as per the use case diagram.

You might also like