Skip to main content
QUICK REVIEW

[Paper Review] Using Large Language Models for Student-Code Guided Test Case Generation in Computer Science Education

Nischal Ashok Kumar, Andrew Lan|arXiv (Cornell University)|Feb 11, 2024
Model-Driven Software Engineering TechniquesComputer Science3 citations
TL;DR

This paper proposes an LLM-based, iterative refinement approach for automatically generating test cases guided by representative student code, using compiler feedback to improve accuracy. It demonstrates that test cases generated this way can effectively measure student knowledge by reflecting actual student errors, as validated on a real-world CS education dataset.

ABSTRACT

In computer science education, test cases are an integral part of programming assignments since they can be used as assessment items to test students' programming knowledge and provide personalized feedback on student-written code. The goal of our work is to propose a fully automated approach for test case generation that can accurately measure student knowledge, which is important for two reasons. First, manually constructing test cases requires expert knowledge and is a labor-intensive process. Second, developing test cases for students, especially those who are novice programmers, is significantly different from those oriented toward professional-level software developers. Therefore, we need an automated process for test case generation to assess student knowledge and provide feedback. In this work, we propose a large language model-based approach to automatically generate test cases and show that they are good measures of student knowledge, using a publicly available dataset that contains student-written Java code. We also discuss future research directions centered on using test cases to help students.

Motivation & Objective

  • To address the labor-intensive challenge of manually creating test cases for novice programmers in CS education.
  • To develop an automated, scalable method for generating test cases that accurately reflect student knowledge and common errors.
  • To leverage large language models (LLMs) and compiler feedback to iteratively refine test case quality.
  • To evaluate the approach on real student code from a public dataset to validate its effectiveness.
  • To explore the use of generated test cases as formative assessment tools and for personalized feedback.

Proposed method

  • The method uses a series of LLM prompts that include representative buggy and correct student code pairs to guide test case generation.
  • Test cases are generated iteratively, with feedback from a Java compiler used to refine subsequent LLM prompts.
  • Each prompt is structured as a JSON-serializable object to ensure machine-readable output and reduce hallucination.
  • Compiler feedback is explicitly formatted as tabular text, detailing test case results on both buggy and correct code.
  • Execution of test cases is monitored via multi-threading and time-outs to prevent infinite loops or run-time errors.
  • The system uses compiler output to identify and correct faulty test cases, improving reliability through iterative refinement.
Figure 1: Visualizing our overall approach for test case generation. TC stands for test case.
Figure 1: Visualizing our overall approach for test case generation. TC stands for test case.

Experimental results

Research questions

  • RQ1Can LLMs generate test cases that accurately reflect student errors when guided by representative student code?
  • RQ2How effective is an iterative refinement process using compiler feedback in improving test case quality?
  • RQ3Can LLM-generated test cases serve as valid assessments of student programming knowledge?
  • RQ4How do the generated test cases compare to those created by human experts in terms of coverage and accuracy?
  • RQ5Can test cases be used to support personalized feedback and adaptive assessment in CS education?

Key findings

  • The approach successfully generates test cases that reflect specific student bugs, as demonstrated in a qualitative case study where test cases correctly exposed differences between buggy and correct code.
  • Test cases generated using the LLM and compiler feedback mechanism were able to distinguish between correct and buggy code, particularly in cases where the bug was context-sensitive (e.g., incorrect handling of 6-7 sequences).
  • The iterative refinement process reduced the likelihood of generating faulty or invalid test cases by incorporating real compiler feedback into subsequent prompts.
  • The method demonstrated feasibility on a real-world dataset, showing that LLMs can be guided by student code to produce assessment-quality test cases.
  • The approach enables scalable, automated test case generation that captures diverse student errors, reducing reliance on manual creation.
  • The system effectively handles run-time errors during test execution through time-bound, multi-threaded execution and feedback-driven correction.
Table 2: Error and frequency distribution for student code with different scores for one problem.
Table 2: Error and frequency distribution for student code with different scores for one problem.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.