TOGA
TOGA uses two fine-tuned transformer classifiers to pick a unit test's oracle: an expected exception or an assertion.
Language · 630 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
At a glance
- Task
- Language
- Parameters
- 249.3M
- Operations
- 630
- Framework
- PyTorch
- Recurrent
- No
- Published
- ICSE 2022
- Cited by
- 5 (as of 30 October 2026)
- Authors
- Elizabeth Dinella, Gabriel Ryan, Todd Mytkowicz, Shuvendu K. Lahiri
- Source
- GitHub: microsoft/toga
- License
- MIT
- Checked
- Passed: the trace was replayed operation by operation and matched the model's own output for this input.
Files
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
Details
- Stable ID
- m20819
- Graph hash
- 8b3efd65efee9f1e478d7bff4ce993f19ee7de5bee1abcf16078261d14347f52
- Skeleton hash
- 70cbca74b11c58863738faf4a06e8b58576f2149adca3204e6f176077251190b
- Architecture hash
- ba218a4e2043b6bb6c389a557451446d2fbece8edd51857c1f349602c7d1d90f
- Diagram SHA-256
- 0ed2ce02b07a0d9c9be793524e0665a0c46895c59df5b1d487d62d03c976e4a8
- TorchLens version
- 2.36.0
- Renderer
- graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
- Check
- Forward pass replayed in PyTorch
What it is
TOGA is a neural method for generating test oracles, the conditions in a unit test that document how a unit is intended to behave. It is a unified transformer-based approach that infers both exceptional and assertion oracles from the context of the focal method. The paper says it can handle units with ambiguous or missing documentation, and even units with a missing implementation.
Instead of generating oracle text freely, TOGA reformulates the problem as a ranking over a small set of likely oracles. It has two components, the Exceptional Oracle Classifier and the Assertion Oracle Ranker. The classifier is a pretrained transformer fine-tuned on a binary decision, whether an exception should be thrown. If no exception is expected, the ranker scores a set of candidate assertions and the highest ranked one becomes the oracle. Both parts start from the pretrained CodeBERT model.
The paper reports 96% accuracy on a held out test dataset that fits its grammar and constraints, a 33% improvement over existing oracle inference approaches. Integrated with the EvoSuite test generation tool, it reports finding 57 real world bugs in the Defects4J Java benchmark. The released artifact notes that its exception model was retrained, so its results differ slightly from the submission.
Key idea. TOGA reformulates test oracle generation as ranking a small set of likely candidate oracles with fine-tuned pretrained transformers, covering both exception and assertion oracles.
- TOGA
- Test Oracle GenerAtion
- test oracle
- neural test oracle
- assertion oracle
- exception oracle
- unit test generation
- oracle inference
- code model
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
Cite the paper
@misc{dinella2022toganeuralmethodtest,
title={TOGA: A Neural Method for Test Oracle Generation},
author={Elizabeth Dinella and Gabriel Ryan and Todd Mytkowicz and Shuvendu K. Lahiri},
year={2022},
eprint={2109.09262},
archivePrefix={arXiv},
primaryClass={cs.SE},
doi={https://doi.org/10.1145/3510003.3510141},
url={https://arxiv.org/abs/2109.09262},
}