Skip to content

Interview Exam - CSV Reader

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 a mock exam problem set used in Programming Foundations 2 course at the Faculty of Computer Science Universitas Indonesia. The code contains a method named read() that accepts two arguments: the filename and the regex pattern used for splitting a line into an array of strings.

 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
28
29
30
31
32
33
34
// For brevity, assume all required classes have been imported.
public class CsvDataReader {

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

    private CsvDataReader() { }

    public static List<String[]> read(String fileName, String regex) {
        List<String[]> entries = new ArrayList<>();
        File csvFile = new File(fileName);

        try (Scanner in = new Scanner(csvFile)) {
            String header = in.nextLine();

            while (in.hasNextLine()) {
                String line = in.nextLine();
                String[] csvEntry = line.split(regex);
                entries.add(csvEntry);
            }
        } catch (FileNotFoundException e) {
            LOGGER.severe(String.format("%s not found", fileName));
            LOGGER.severe("Immediately return an empty list");

            return Collections.emptyList();
        } catch (PatternSyntaxException e) {
            LOGGER.severe(String.format("%s cannot be splitted using regex %s", line, regex));
            LOGGER.severe("Immediately return an empty list");

            return Collections.emptyList();
        }

        return entries;
    }
}

The CSV reader implementation above attempts to read a file and tries to parse each row read from the file using the given regex pattern in the tokenisation process. Each row is parsed into an array of string and stored into a list. The resulting list is then returned to the caller.

The implementation also contains some error handling. If the given file is not found, then the method will return an empty list instead. Similarly, if there is a line that cannot be splitted using the given regex pattern, then the method will return an empty list.

Part 1: Input Space Partitioning

Estimated time to complete: 5 minutes

You are asked to design an input space model for the read() 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 read() 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 read() 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 Jahns Christian Albert and the teaching assistants of Programming Foundations 2 course 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