Test Case Concepts

Asked 2 years ago, Updated 2 years ago, 30 views

This time, we are going to create a test case for each method, but it is stuck from the first method.
Create a Test Case

All Normal Input Data Normal Patterns
Abnormal Input Data Abnormal Patterns All
Boundary Value If I/O element is a boundary value and a value before and after it
Multiple Elements (Boundary Value) If Input/Output Elements are List Arrays and the Item Is a Boundary Value
Special Value If I/O element is a special value (zero, null, empty string, etc.)
Multiple Elements (Number) If the input/output elements are a list array and the number is 0, 1, or n
Multiple elements (special value) If input/output elements are list arrays and the item is special value
Branch Cover All Branch Paths
Repeat exhaust loop 0 times, 1 time, normal, maximum, maximum - 1 time

The actual method to be tested is

private static final String STRING_EMPTY=";

public void addValue(String reportFieldKey, String value) {
        keyValue = new FieldKeyValuePair();

        if(reportFieldKey==null){
            keyValue.setReportFieldKey(STRING_EMPTY);
        } else {
            keyValue.setReportFieldKey(reportFieldKey);
        }

        if(value==null){
            keyValue.setValue(STRING_EMPTY);
        } else {
            keyValue.setValue(value);
        }

        recordInfo.add(keyValue);
}

Setting parameters received like this to a class called FieldKeyValuePair
I don't know how to think about this abnormal system.
When null comes in, I control it to include empty strings, so I can do a special value pattern, but I can only think of one normal system.

What else do you think of this test case?
I would appreciate it if you could let me know.

java

2022-09-30 10:53

1 Answers

Creating a test from the code being tested will not save you from missing implementation.
Create based on specifications (requirements) rather than from the code being tested.

The question only contains the code to be tested, so I have no choice but to guess
For example, if I were to write a test code, I'd like to give you an example.

If a FieldKeyValuePair object with the key value specified by the argument rereportFieldKey で already exists in recordInfo, what behavior do you expect?
(1)Overwrite
(2)Make it an error (for example, xxxxException is dropped...)
(3)Add the same key regardless

I can only think of this as (3) when I create a test code from the code, but is the specification of addValue() really (3)?
(1)Test Code (Normal) to Verify Overrides If
(2)Test Code for Error (xxxxException Throws)
You must create . → Check the specifications.

The rest is how far to go...
Does the specification allow control characters (line feed code or tab code etc...) for reportFieldKey, value values?
You must create these test codes if you do not want to.

If it's all acceptable... Is there any abnormal test?


2022-09-30 10:53

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.