Skip to content

Interview Exam - Date Parser

Estimated time to read the description: 5 minutes

You may open Google, Stack Overflow, textbook, slides, etc. However, please be aware that your time is very limited. It is better to focus on doing the tasks.

The following code is taken and modified from Pacilkom Bot codebase, a bonus project for Advanced Programming Even '17/'18. The code contains a method named parseDateParameter() that accepts a string which will be parsed into an instance of Map.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// For brevity, assume all required classes have been imported.
public class InputParser {

    private static final Logger LOGGER = Logger.getLogger(InputParser.class.getName());

    private DataParser() { }

    public Map<String, String> parseDateParameter(String text) {
        Map<String, String> result = new HashMap<>();

        try {
            if (text.isEmpty()) return result;

            // Add new key value pair
            String[] params = text.split(" ");
            String[] keys = {"year", "term", "day"};

            if (params.length == 3) result.put(keys[2], params[2]);
            if (params.length == 2) result.put(keys[1], params[1]);
            if (params.length == 1) result.put(keys[0], params[0]);
        } catch (NullPointerException e) {
            LOGGER.warning("User input text is null. Returning an empty list.");
        } finally {
            return result;
        }
    }
}

The implementation above attempts to parse a user input into a Map by performing string tokenisation into an array of string parameters. Then, a string parameter will be put into the Map. Specifically, the string parameter at index position 0, 1, or 2 that will be put into the Map. The actual position depends on the length of the array. Otherwise, if the number of string parameters are zero or greater than three, then the Map will be empty and returned to the caller.

In addition, the implementation also contains an error handling where the method will return an empty Map if the input text is null.

Part 1: Input Space Partitioning

Estimated time to complete: 5 minutes

You are asked to design an input space model for the parseDateParameter() method by following a functionality-based approach. The information required to develop the model can be derived by reading the code snippet and understanding the problem description. Once you have developed the model, create the test requirement and the test cases.

Your tasks are as follows:

  1. Determine the characteristics and the partition of the parseDateParameter() method.
  2. Based on the input space model that you have created, create the test requirement and the test cases based on certain coverage criteria chosen by the proctor.

Possible coverage criteria choices:

  • All Combinations Coverage (ACoC)
  • Each Choice Coverage (ECC)
  • Pair-Wise Coverage (PWC)
  • Base Choice Coverage (BCC)

Note: You do not have to write all test cases due to the time limit. You need to demonstrate that the subset of your test cases valid with the chosen coverage criteria.

Write your answer in a sheet of paper or Microsoft Word/Google Docs document. You may include illustrations in your answer. Please prepare to present your answer remotely via Zoom/Google Hangouts during discussion time.

Part 2: Graph Coverage

Estimated time to complete: 5 minutes

You are asked to design a control flow graph (CFG), prepare the test requirement, and create the test paths.

Your tasks are as follows:

  1. Create the CFG of the parseDateParameter() method.
  2. Based on the CFG that you have created, create the test requirement and the test paths based on certain coverage criteria chosen by the proctor.

Possible coverage criteria choices:

  • Node Coverage (NC)
  • Edge Coverage (EC)
  • Edge-Pair Coverage (EPC)

Note: You do not have to write all test paths due to the time limit. You need to demonstrate that the subset of your test paths valid with the chosen coverage criteria.

Write your answer in a sheet of paper or Microsoft Word/Google Docs document. You may include illustrations in your answer. Please prepare to present your answer remotely via Zoom/Google Hangouts during discussion time.

Part 3: Discussion

Estimated time: 10 minutes

You are asked to present your answers to the given problems and also to have one-on-one interview with the proctor during the discussion time.

The list of topics that might be discussed is as follows:

  • Code coverage (line coverage)
  • Test-Driven Development (TDD)
  • Test isolation
  • Writing test cases in Java (JUnit)/Python (unittest and Django)/PHP (PHPUnit)
  • Your experience in conducting SQA activities in academics and/or work environment
  • The ideas of mutation testing
  • CI/CD, especially in GitLab
  • Monitoring
  • And many more that may still related to SQA

Acknowledgements

Credits to 72-pacilkom-bot as a whole for developing the original code used in this problem set.


Last update: 2022-10-26 04:54:16
Created: 2022-10-26 04:54:16