exp1 fin
This commit is contained in:
BIN
Experiment.pdf
Normal file
BIN
Experiment.pdf
Normal file
Binary file not shown.
57
experiment1/.classpath
Normal file
57
experiment1/.classpath
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" path="target/generated-sources/annotations">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="ignore_optional_problems" value="true"/>
|
||||||
|
<attribute name="m2e-apt" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="ignore_optional_problems" value="true"/>
|
||||||
|
<attribute name="m2e-apt" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
</classpath>
|
||||||
34
experiment1/.project
Normal file
34
experiment1/.project
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>experiment1</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
|
</natures>
|
||||||
|
<filteredResources>
|
||||||
|
<filter>
|
||||||
|
<id>1733408540557</id>
|
||||||
|
<name></name>
|
||||||
|
<type>30</type>
|
||||||
|
<matcher>
|
||||||
|
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||||
|
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||||
|
</matcher>
|
||||||
|
</filter>
|
||||||
|
</filteredResources>
|
||||||
|
</projectDescription>
|
||||||
2
experiment1/.settings/org.eclipse.jdt.apt.core.prefs
Normal file
2
experiment1/.settings/org.eclipse.jdt.apt.core.prefs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.apt.aptEnabled=false
|
||||||
9
experiment1/.settings/org.eclipse.jdt.core.prefs
Normal file
9
experiment1/.settings/org.eclipse.jdt.core.prefs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=17
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.processAnnotations=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.release=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.source=17
|
||||||
4
experiment1/.settings/org.eclipse.m2e.core.prefs
Normal file
4
experiment1/.settings/org.eclipse.m2e.core.prefs
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
activeProfiles=
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
resolveWorkspaceProjects=true
|
||||||
|
version=1
|
||||||
50
experiment1/pom.xml
Normal file
50
experiment1/pom.xml
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>com.example</groupId>
|
||||||
|
<artifactId>experiment1</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<!-- Set the Java version here -->
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<configuration>
|
||||||
|
<release>17</release> <!-- Prefer "release" for modern Java -->
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
<configuration>
|
||||||
|
<mainClass>com.example.App</mainClass>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>3.0.0-M7</version> <!-- Ensure at least version 2.22.0 -->
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- JUnit 5 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter</artifactId>
|
||||||
|
<version>5.10.0</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
93
experiment1/report.md
Normal file
93
experiment1/report.md
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
# Decision Table
|
||||||
|
|-----------------+------------+---------------+------------------------|
|
||||||
|
| number_of_items | total_cost | delivery_time | cost |
|
||||||
|
|-----------------+------------+---------------+------------------------|
|
||||||
|
| <= 3 | <= 100 | NEXT_DAY | 25 |
|
||||||
|
|-----------------+------------+---------------+------------------------|
|
||||||
|
| <=3 | <= 100 | SECOND_DAY | 10 |
|
||||||
|
|-----------------+------------+---------------+------------------------|
|
||||||
|
| <= 3 | <= 100 | THIS_WEEK | number_of_items * 1.50 |
|
||||||
|
|-----------------+------------+---------------+------------------------|
|
||||||
|
| <= 3 | > 100 | NEXT_DAY | 35.00 |
|
||||||
|
|-----------------+------------+---------------+------------------------|
|
||||||
|
| <= 3 | > 100 | SECOND_DAY | 15.00 |
|
||||||
|
|-----------------+------------+---------------+------------------------|
|
||||||
|
| <= 3 | > 100 | THIS_WEEK | 10.00 |
|
||||||
|
|-----------------+------------+---------------+------------------------|
|
||||||
|
| > 3 | <= 100 | NEXT_DAY | number_of_items * 6.00 |
|
||||||
|
|-----------------+------------+---------------+------------------------|
|
||||||
|
| > 3 | <= 100 | SECOND_DAY | number_of_items * 2.50 |
|
||||||
|
|-----------------+------------+---------------+------------------------|
|
||||||
|
| > 3 | <= 100 | THIS_WEEK | 0.00 |
|
||||||
|
|-----------------+------------+---------------+------------------------|
|
||||||
|
| > 3 | > 100 | NEXT_DAY | number_of_items * 7.50 |
|
||||||
|
|-----------------+------------+---------------+------------------------|
|
||||||
|
| > 3 | > 100 | SECOND_DAY | number_of_items * 3.50 |
|
||||||
|
|-----------------+------------+---------------+------------------------|
|
||||||
|
| > 3 | > 100 | THIS_WEEK | number_of_items * 2.50 |
|
||||||
|
|-----------------+------------+---------------+------------------------|
|
||||||
|
|
||||||
|
time take to generate this : 14.20 min (including song selection 😜 )
|
||||||
|
|
||||||
|
|
||||||
|
# Equivalance testing:
|
||||||
|
|
||||||
|
## Input parameters:
|
||||||
|
* number of item
|
||||||
|
* Positive integers are the valid values.
|
||||||
|
* total cost
|
||||||
|
* Positive numbers are the valid values.
|
||||||
|
* delivery time
|
||||||
|
* NEXT_DAY , SECOND_DAY and THIS_WEEK are the valid values.
|
||||||
|
|
||||||
|
|
||||||
|
## Equivalance partitions
|
||||||
|
|
||||||
|
|-----------------|----------------|---------------------------------|----------------|
|
||||||
|
| Input | Partition Type | Partition Condition | Selected Value |
|
||||||
|
|-----------------|----------------|---------------------------------|----------------|
|
||||||
|
| number_of_items | Valid | <= 3 | 3 |
|
||||||
|
| | Valid | > 3 | 4 |
|
||||||
|
| | Invalid | <= 0 | -1 |
|
||||||
|
|-----------------|----------------|---------------------------------|----------------|
|
||||||
|
| total_cost | Valid | <= 100 | 100 |
|
||||||
|
| | Valid | > 100 | 101 |
|
||||||
|
| | Invalid | < 0 | -2 |
|
||||||
|
|-----------------|----------------|---------------------------------|----------------|
|
||||||
|
| delivery_time | Valid | NEXT_DAY, SECOND_DAY, THIS_WEEK | SECOND_DAY |
|
||||||
|
| | Invalid | Null or unsupported value | null |
|
||||||
|
|-----------------|----------------|---------------------------------|----------------|
|
||||||
|
|
||||||
|
## Test cases
|
||||||
|
|
||||||
|
|-----------|-----------------|------------|---------------|------------------|---------------------------------|
|
||||||
|
| Test Case | number_of_items | total_cost | delivery_time | Partition Type | Expected Outcome |
|
||||||
|
|-----------|-----------------|------------|---------------|------------------|---------------------------------|
|
||||||
|
| 1 | 3 | 100 | NEXT_DAY | All Valid | 25.00 |
|
||||||
|
| 2 | 3 | 150 | SECOND_DAY | All Valid | 15.00 |
|
||||||
|
| 3 | 4 | 100 | THIS_WEEK | All Valid | 0.00 |
|
||||||
|
| 4 | 4 | 150 | NEXT_DAY | All Valid | 30.00 |
|
||||||
|
| 5 | -1 | 100 | NEXT_DAY | Invalid Items | Exception |
|
||||||
|
| 6 | 3 | -50 | SECOND_DAY | Invalid Cost | Exception |
|
||||||
|
| 7 | 3 | 100 | null | Invalid Delivery | Exception |
|
||||||
|
|-----------|-----------------|------------|---------------|------------------|---------------------------------|
|
||||||
|
|
||||||
|
# Boundary Value
|
||||||
|
|
||||||
|
|-----------------|------------|
|
||||||
|
| Input | Boundaries |
|
||||||
|
|-----------------|------------|
|
||||||
|
| number_of_items | -1 |
|
||||||
|
| | 0 |
|
||||||
|
| | 1 |
|
||||||
|
| | 3 |
|
||||||
|
| | 4 |
|
||||||
|
|-----------------|------------|
|
||||||
|
| total_cost | -1 |
|
||||||
|
| | 0 |
|
||||||
|
| | 1 |
|
||||||
|
| | 100 |
|
||||||
|
| | 101 |
|
||||||
|
|-----------------|------------|
|
||||||
|
| delivery_time | n/a |
|
||||||
|
|-----------------|------------|
|
||||||
11
experiment1/src/main/java/com/example/App.java
Normal file
11
experiment1/src/main/java/com/example/App.java
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package com.example;
|
||||||
|
import com.example.DecisionTable;
|
||||||
|
|
||||||
|
public class App
|
||||||
|
{
|
||||||
|
public static void main( String[] args )
|
||||||
|
{
|
||||||
|
System.out.println("helo");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
81
experiment1/src/main/java/com/example/DecisionTable.java
Normal file
81
experiment1/src/main/java/com/example/DecisionTable.java
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
package com.example;
|
||||||
|
|
||||||
|
public class DecisionTable {
|
||||||
|
|
||||||
|
private static final int purchase_amount_limit = 100;
|
||||||
|
private static final int number_of_items_limit = 3;
|
||||||
|
|
||||||
|
|
||||||
|
public Double calculate_costs(final int number_of_items, final double total_cost, final SHIPPING_TIME delivery_time) {
|
||||||
|
if (number_of_items <= 0 || total_cost <= 0) {
|
||||||
|
throw new IllegalArgumentException("Unsupported value");
|
||||||
|
}
|
||||||
|
switch (delivery_time) {
|
||||||
|
case NEXT_DAY:
|
||||||
|
return calculate_next_day_delivery_cost(number_of_items,total_cost);
|
||||||
|
case SECOND_DAY:
|
||||||
|
return calculate_second_day_delivery_cost(number_of_items,total_cost);
|
||||||
|
case THIS_WEEK:
|
||||||
|
return calculate_week_delivery_cost(number_of_items,total_cost);
|
||||||
|
default:
|
||||||
|
throw new UnsupportedOperationException("Unsupported option: " + delivery_time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public double calculate_next_day_delivery_cost(final int number_of_items, final double total_cost) {
|
||||||
|
|
||||||
|
if (total_cost > 100) {
|
||||||
|
if (number_of_items > 3) {
|
||||||
|
return number_of_items * 7.50;
|
||||||
|
} else {
|
||||||
|
return 35.00;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (number_of_items > 3) {
|
||||||
|
return number_of_items * 6.00;
|
||||||
|
} else {
|
||||||
|
return 25;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public double calculate_second_day_delivery_cost(final int number_of_items, final double total_cost) {
|
||||||
|
|
||||||
|
if (total_cost > 100) {
|
||||||
|
if (number_of_items > 3) {
|
||||||
|
return number_of_items * 3.50;
|
||||||
|
} else {
|
||||||
|
return 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (number_of_items > 3) {
|
||||||
|
return number_of_items * 2.50;
|
||||||
|
} else {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public double calculate_week_delivery_cost(final int number_of_items, final double total_cost) {
|
||||||
|
|
||||||
|
if (total_cost > 100) {
|
||||||
|
if (number_of_items > 3) {
|
||||||
|
return number_of_items * 2.50;
|
||||||
|
} else {
|
||||||
|
return 10.00;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (number_of_items > 3) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return number_of_items * 1.50;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
7
experiment1/src/main/java/com/example/SHIPPING_TIME.java
Normal file
7
experiment1/src/main/java/com/example/SHIPPING_TIME.java
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package com.example;
|
||||||
|
|
||||||
|
public enum SHIPPING_TIME {
|
||||||
|
NEXT_DAY,
|
||||||
|
SECOND_DAY,
|
||||||
|
THIS_WEEK
|
||||||
|
}
|
||||||
157
experiment1/src/test/java/com/example/AppTest.java
Normal file
157
experiment1/src/test/java/com/example/AppTest.java
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
package com.example;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class AppTest {
|
||||||
|
|
||||||
|
public class Test_scenario {
|
||||||
|
public double total_cost;
|
||||||
|
public int number_of_items;
|
||||||
|
public SHIPPING_TIME delivery_time;
|
||||||
|
public double exp_cost;
|
||||||
|
|
||||||
|
public Test_scenario(double total_cost,
|
||||||
|
int number_of_items,
|
||||||
|
SHIPPING_TIME delivery_time,
|
||||||
|
double exp_cost) {
|
||||||
|
this.total_cost = total_cost;
|
||||||
|
this.number_of_items = number_of_items;
|
||||||
|
this.delivery_time = delivery_time;
|
||||||
|
this.exp_cost = exp_cost;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Took 26 min to write tests, mvn execution time was
|
||||||
|
* mvn test 4.59s user 0.31s system 456% cpu 1.073 total
|
||||||
|
* According to mvn test took
|
||||||
|
* Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.008 sec
|
||||||
|
* generated cases: 12
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void decision_table_testing() {
|
||||||
|
DecisionTable dt = new DecisionTable();
|
||||||
|
|
||||||
|
List<Test_scenario> scenarios = new ArrayList<>();
|
||||||
|
scenarios.add(new Test_scenario(100.0,3,SHIPPING_TIME.NEXT_DAY,25.0));
|
||||||
|
scenarios.add(new Test_scenario(100.0,3,SHIPPING_TIME.SECOND_DAY,10.0));
|
||||||
|
scenarios.add(new Test_scenario(100.0,3,SHIPPING_TIME.THIS_WEEK,4.5));
|
||||||
|
scenarios.add(new Test_scenario(150.0,3,SHIPPING_TIME.NEXT_DAY,35.0));
|
||||||
|
scenarios.add(new Test_scenario(150.0,3,SHIPPING_TIME.SECOND_DAY,15.0));
|
||||||
|
scenarios.add(new Test_scenario(150.0,3,SHIPPING_TIME.THIS_WEEK,10.0));
|
||||||
|
scenarios.add(new Test_scenario(100.0,6,SHIPPING_TIME.NEXT_DAY,36.0));
|
||||||
|
scenarios.add(new Test_scenario(100.0,6,SHIPPING_TIME.SECOND_DAY,15.0));
|
||||||
|
scenarios.add(new Test_scenario(100.0,6,SHIPPING_TIME.THIS_WEEK,0.0));
|
||||||
|
scenarios.add(new Test_scenario(150.0,6,SHIPPING_TIME.NEXT_DAY,45.0));
|
||||||
|
scenarios.add(new Test_scenario(150.0,6,SHIPPING_TIME.SECOND_DAY,21.0));
|
||||||
|
scenarios.add(new Test_scenario(150.0,6,SHIPPING_TIME.THIS_WEEK,15.0));
|
||||||
|
|
||||||
|
for (Test_scenario scenario : scenarios) {
|
||||||
|
assertEquals(scenario.exp_cost,
|
||||||
|
dt.calculate_costs(scenario.number_of_items,
|
||||||
|
scenario.total_cost,
|
||||||
|
scenario.delivery_time),
|
||||||
|
0.01,
|
||||||
|
String.format("Failed for Items: %d, Cost: %.2f, Delivery: %s",
|
||||||
|
scenario.number_of_items, scenario.total_cost,
|
||||||
|
scenario.delivery_time));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Took 40 minutes to create and implement tests
|
||||||
|
* mvn test 6.49s user 0.32s system 474% cpu 1.435 total
|
||||||
|
* Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.028 s - in com.example.AppTest
|
||||||
|
* generated cases: 7
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void equivalance_testing() {
|
||||||
|
|
||||||
|
DecisionTable dt = new DecisionTable();
|
||||||
|
|
||||||
|
List<Test_scenario> valid_scenarios = new ArrayList<>();
|
||||||
|
List<Test_scenario> invalid_scenarios = new ArrayList<>();
|
||||||
|
valid_scenarios.add(new Test_scenario(100.0,3,SHIPPING_TIME.NEXT_DAY,25.0));
|
||||||
|
valid_scenarios.add(new Test_scenario(150.0,3,SHIPPING_TIME.SECOND_DAY,15.0));
|
||||||
|
valid_scenarios.add(new Test_scenario(100.0,4,SHIPPING_TIME.THIS_WEEK,0.0));
|
||||||
|
valid_scenarios.add(new Test_scenario(150.0,4,SHIPPING_TIME.NEXT_DAY,30.0));
|
||||||
|
|
||||||
|
invalid_scenarios.add(new Test_scenario(100.0,-1,SHIPPING_TIME.NEXT_DAY,0));
|
||||||
|
invalid_scenarios.add(new Test_scenario(-50.0,3,SHIPPING_TIME.SECOND_DAY,0));
|
||||||
|
invalid_scenarios.add(new Test_scenario(100.0,3,null,0));
|
||||||
|
|
||||||
|
for (Test_scenario scenario : valid_scenarios) {
|
||||||
|
assertEquals(scenario.exp_cost,
|
||||||
|
dt.calculate_costs(scenario.number_of_items,
|
||||||
|
scenario.total_cost,
|
||||||
|
scenario.delivery_time),
|
||||||
|
0.01,
|
||||||
|
String.format("Failed for Items: %d, Cost: %.2f, Delivery: %s",
|
||||||
|
scenario.number_of_items, scenario.total_cost,
|
||||||
|
scenario.delivery_time));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Test_scenario scenario : invalid_scenarios) {
|
||||||
|
assertThrows(Throwable.class, () -> dt.calculate_costs(
|
||||||
|
scenario.number_of_items,
|
||||||
|
scenario.total_cost,
|
||||||
|
scenario.delivery_time),
|
||||||
|
String.format("Failed for Items: %d, Cost: %.2f, Delivery: %s",
|
||||||
|
scenario.number_of_items, scenario.total_cost,
|
||||||
|
scenario.delivery_time));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Took 24 minutes to create and implement tests
|
||||||
|
* mvn test 7.01s user 0.31s system 503% cpu 1.454 total
|
||||||
|
* Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.026 s - in com.example.AppTest
|
||||||
|
* generated cases: 9
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void boundary_value_testing() {
|
||||||
|
|
||||||
|
DecisionTable dt = new DecisionTable();
|
||||||
|
List<Test_scenario> valid_scenarios = new ArrayList<>();
|
||||||
|
List<Test_scenario> invalid_scenarios = new ArrayList<>();
|
||||||
|
invalid_scenarios.add(new Test_scenario(100.0,-1,SHIPPING_TIME.NEXT_DAY,25.0));
|
||||||
|
invalid_scenarios.add(new Test_scenario(100.0,0,SHIPPING_TIME.NEXT_DAY,25.0));
|
||||||
|
valid_scenarios.add(new Test_scenario(100.0,1,SHIPPING_TIME.NEXT_DAY,25.0));
|
||||||
|
valid_scenarios.add(new Test_scenario(100.0,3,SHIPPING_TIME.NEXT_DAY,25.0));
|
||||||
|
valid_scenarios.add(new Test_scenario(100.0,4,SHIPPING_TIME.NEXT_DAY,24.0));
|
||||||
|
invalid_scenarios.add(new Test_scenario(-1.0,1,SHIPPING_TIME.NEXT_DAY,25.0));
|
||||||
|
invalid_scenarios.add(new Test_scenario(0.0,1,SHIPPING_TIME.NEXT_DAY,25.0));
|
||||||
|
valid_scenarios.add(new Test_scenario(1.0,3,SHIPPING_TIME.NEXT_DAY,25.0));
|
||||||
|
valid_scenarios.add(new Test_scenario(101.0,3,SHIPPING_TIME.NEXT_DAY,35.0));
|
||||||
|
|
||||||
|
for (Test_scenario scenario : valid_scenarios) {
|
||||||
|
assertEquals(scenario.exp_cost,
|
||||||
|
dt.calculate_costs(scenario.number_of_items,
|
||||||
|
scenario.total_cost,
|
||||||
|
scenario.delivery_time),
|
||||||
|
0.01,
|
||||||
|
String.format("Failed for Items: %d, Cost: %.2f, Delivery: %s",
|
||||||
|
scenario.number_of_items, scenario.total_cost,
|
||||||
|
scenario.delivery_time));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Test_scenario scenario : invalid_scenarios) {
|
||||||
|
assertThrows(Throwable.class, () -> dt.calculate_costs(
|
||||||
|
scenario.number_of_items,
|
||||||
|
scenario.total_cost,
|
||||||
|
scenario.delivery_time),
|
||||||
|
String.format("Failed for Items: %d, Cost: %.2f, Delivery: %s",
|
||||||
|
scenario.number_of_items, scenario.total_cost,
|
||||||
|
scenario.delivery_time));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
com/example/DecisionTable$1.class
|
||||||
|
com/example/App.class
|
||||||
|
com/example/DecisionTable.class
|
||||||
|
com/example/SHIPPING_TIME.class
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
/home/alican/school/test/experiment/experiment1/src/main/java/com/example/SHIPPING_TIME.java
|
||||||
|
/home/alican/school/test/experiment/experiment1/src/main/java/com/example/App.java
|
||||||
|
/home/alican/school/test/experiment/experiment1/src/main/java/com/example/DecisionTable.java
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
com/example/AppTest$Test_scenario.class
|
||||||
|
com/example/AppTest.class
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
/home/alican/school/test/experiment/experiment1/src/test/java/com/example/AppTest.java
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report-3.0.xsd" version="3.0" name="com.example.AppTest" time="0.03" tests="3" errors="0" skipped="0" failures="0">
|
||||||
|
<properties>
|
||||||
|
<property name="java.specification.version" value="17"/>
|
||||||
|
<property name="sun.jnu.encoding" value="UTF-8"/>
|
||||||
|
<property name="java.class.path" value="/home/alican/school/test/experiment/experiment1/target/test-classes:/home/alican/school/test/experiment/experiment1/target/classes:/home/alican/.m2/repository/org/junit/jupiter/junit-jupiter/5.10.0/junit-jupiter-5.10.0.jar:/home/alican/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.10.0/junit-jupiter-api-5.10.0.jar:/home/alican/.m2/repository/org/opentest4j/opentest4j/1.3.0/opentest4j-1.3.0.jar:/home/alican/.m2/repository/org/junit/platform/junit-platform-commons/1.10.0/junit-platform-commons-1.10.0.jar:/home/alican/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar:/home/alican/.m2/repository/org/junit/jupiter/junit-jupiter-params/5.10.0/junit-jupiter-params-5.10.0.jar:/home/alican/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.10.0/junit-jupiter-engine-5.10.0.jar:/home/alican/.m2/repository/org/junit/platform/junit-platform-engine/1.10.0/junit-platform-engine-1.10.0.jar:"/>
|
||||||
|
<property name="java.vm.vendor" value="Debian"/>
|
||||||
|
<property name="sun.arch.data.model" value="64"/>
|
||||||
|
<property name="java.vendor.url" value="https://tracker.debian.org/openjdk-17"/>
|
||||||
|
<property name="os.name" value="Linux"/>
|
||||||
|
<property name="java.vm.specification.version" value="17"/>
|
||||||
|
<property name="sun.java.launcher" value="SUN_STANDARD"/>
|
||||||
|
<property name="user.country" value="US"/>
|
||||||
|
<property name="sun.boot.library.path" value="/usr/lib/jvm/java-17-openjdk-amd64/lib"/>
|
||||||
|
<property name="sun.java.command" value="/home/alican/school/test/experiment/experiment1/target/surefire/surefirebooter-20241206211311401_3.jar /home/alican/school/test/experiment/experiment1/target/surefire 2024-12-06T21-13-11_276-jvmRun1 surefire-20241206211311401_1tmp surefire_0-20241206211311401_2tmp"/>
|
||||||
|
<property name="jdk.debug" value="release"/>
|
||||||
|
<property name="surefire.test.class.path" value="/home/alican/school/test/experiment/experiment1/target/test-classes:/home/alican/school/test/experiment/experiment1/target/classes:/home/alican/.m2/repository/org/junit/jupiter/junit-jupiter/5.10.0/junit-jupiter-5.10.0.jar:/home/alican/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.10.0/junit-jupiter-api-5.10.0.jar:/home/alican/.m2/repository/org/opentest4j/opentest4j/1.3.0/opentest4j-1.3.0.jar:/home/alican/.m2/repository/org/junit/platform/junit-platform-commons/1.10.0/junit-platform-commons-1.10.0.jar:/home/alican/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar:/home/alican/.m2/repository/org/junit/jupiter/junit-jupiter-params/5.10.0/junit-jupiter-params-5.10.0.jar:/home/alican/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.10.0/junit-jupiter-engine-5.10.0.jar:/home/alican/.m2/repository/org/junit/platform/junit-platform-engine/1.10.0/junit-platform-engine-1.10.0.jar:"/>
|
||||||
|
<property name="sun.cpu.endian" value="little"/>
|
||||||
|
<property name="user.home" value="/home/alican"/>
|
||||||
|
<property name="user.language" value="en"/>
|
||||||
|
<property name="java.specification.vendor" value="Oracle Corporation"/>
|
||||||
|
<property name="java.version.date" value="2024-10-15"/>
|
||||||
|
<property name="java.home" value="/usr/lib/jvm/java-17-openjdk-amd64"/>
|
||||||
|
<property name="file.separator" value="/"/>
|
||||||
|
<property name="basedir" value="/home/alican/school/test/experiment/experiment1"/>
|
||||||
|
<property name="java.vm.compressedOopsMode" value="Zero based"/>
|
||||||
|
<property name="line.separator" value=" "/>
|
||||||
|
<property name="java.vm.specification.vendor" value="Oracle Corporation"/>
|
||||||
|
<property name="java.specification.name" value="Java Platform API Specification"/>
|
||||||
|
<property name="surefire.real.class.path" value="/home/alican/school/test/experiment/experiment1/target/surefire/surefirebooter-20241206211311401_3.jar"/>
|
||||||
|
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
|
||||||
|
<property name="java.runtime.version" value="17.0.13+11-Debian-2deb12u1"/>
|
||||||
|
<property name="user.name" value="alican"/>
|
||||||
|
<property name="path.separator" value=":"/>
|
||||||
|
<property name="os.version" value="6.1.0-18-amd64"/>
|
||||||
|
<property name="java.runtime.name" value="OpenJDK Runtime Environment"/>
|
||||||
|
<property name="file.encoding" value="UTF-8"/>
|
||||||
|
<property name="java.vm.name" value="OpenJDK 64-Bit Server VM"/>
|
||||||
|
<property name="localRepository" value="/home/alican/.m2/repository"/>
|
||||||
|
<property name="java.vendor.url.bug" value="https://bugs.debian.org/openjdk-17"/>
|
||||||
|
<property name="java.io.tmpdir" value="/tmp"/>
|
||||||
|
<property name="java.version" value="17.0.13"/>
|
||||||
|
<property name="user.dir" value="/home/alican/school/test/experiment/experiment1"/>
|
||||||
|
<property name="os.arch" value="amd64"/>
|
||||||
|
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
|
||||||
|
<property name="native.encoding" value="UTF-8"/>
|
||||||
|
<property name="java.library.path" value="/usr/java/packages/lib:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib"/>
|
||||||
|
<property name="java.vm.info" value="mixed mode, sharing"/>
|
||||||
|
<property name="java.vendor" value="Debian"/>
|
||||||
|
<property name="java.vm.version" value="17.0.13+11-Debian-2deb12u1"/>
|
||||||
|
<property name="java.specification.maintenance.version" value="1"/>
|
||||||
|
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
|
||||||
|
<property name="java.class.version" value="61.0"/>
|
||||||
|
</properties>
|
||||||
|
<testcase name="decision_table_testing" classname="com.example.AppTest" time="0.016"/>
|
||||||
|
<testcase name="equivalance_testing" classname="com.example.AppTest" time="0.001"/>
|
||||||
|
<testcase name="boundary_value_testing" classname="com.example.AppTest" time="0.001"/>
|
||||||
|
</testsuite>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Test set: com.example.AppTest
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.03 s - in com.example.AppTest
|
||||||
Reference in New Issue
Block a user