# ⬢ truffle-tck 25.6.0-elide.4
Every page: [llms.txt](llms.txt), or all in one file: [llms-full.txt](llms-full.txt)
API reference for truffle-tck.
## Packages
- [`com.oracle.truffle.tck`](com/oracle/truffle/tck/index.md): Contains testing utilities like com.oracle.truffle.tck.DebuggerTester and com.oracle.truffle.tck.TruffleRunner.
- [`com.oracle.truffle.tck.impl`](com/oracle/truffle/tck/impl/index.md): No description.
## Types in `com.oracle.truffle.tck`
- [`DebuggerTester`](com/oracle/truffle/tck/DebuggerTester.md) (class): Test utility class that makes it easier to test and debug debugger functionality for guest languages.
- [`DebuggerTester.PositionPredicate`](com/oracle/truffle/tck/DebuggerTester.PositionPredicate.md) (interface): Predicate of testable positions.
- [`TruffleRunner`](com/oracle/truffle/tck/TruffleRunner.md) (class): JUnit test runner for unit testing Truffle AST interpreters.
- [`TruffleRunner.Inject`](com/oracle/truffle/tck/TruffleRunner.Inject.md) (annotation interface): A parameter annotated with Inject specifies the RootNode of the test AST.
- [`TruffleRunner.ParametersFactory`](com/oracle/truffle/tck/TruffleRunner.ParametersFactory.md) (class): ParametersRunnerFactory for testing Truffle AST interpreters using Parameterized unit tests.
- [`TruffleRunner.RunWithPolyglotRule`](com/oracle/truffle/tck/TruffleRunner.RunWithPolyglotRule.md) (class): JUnit rule to run the tests in the context of a polyglot engine.
- [`TruffleRunner.Warmup`](com/oracle/truffle/tck/TruffleRunner.Warmup.md) (annotation interface): A test method can be annotated with Warmup to specify how many warmup iterations of a test should be done before the Truffle tree is compiled.
- [`TruffleTestInvokerTruffleTestInvokerLanguageProvider`](com/oracle/truffle/tck/TruffleTestInvokerTruffleTestInvokerLanguageProvider.md) (class): No description.
## Types in `com.oracle.truffle.tck.impl`
- [`PolyglotEngineWithJavaScript`](com/oracle/truffle/tck/impl/PolyglotEngineWithJavaScript.md) (class): Tests with code snippets referencing JavaScript (executed only when an implementation of JavaScript is around).
- [`PolyglotEngineWithJavaScript.Moment`](com/oracle/truffle/tck/impl/PolyglotEngineWithJavaScript.Moment.md) (class): No description.
- [`PolyglotEngineWithR`](com/oracle/truffle/tck/impl/PolyglotEngineWithR.md) (class): Tests with code snippets in R language (executed only when an implementation of R is around).
- [`PolyglotEngineWithRuby`](com/oracle/truffle/tck/impl/PolyglotEngineWithRuby.md) (class): Tests with code snippets referencing Ruby (executed only when implementation of Ruby is around).
- [`TckLanguage`](com/oracle/truffle/tck/impl/TckLanguage.md) (class): No description.
- [`TckLanguageProvider`](com/oracle/truffle/tck/impl/TckLanguageProvider.md) (class): No description.
- [`TruffleLanguageRunner`](com/oracle/truffle/tck/impl/TruffleLanguageRunner.md) (abstract class): No description.
- [`TruffleLanguageRunner.JavaScriptRunner`](com/oracle/truffle/tck/impl/TruffleLanguageRunner.JavaScriptRunner.md) (class): No description.
- [`TruffleLanguageRunner.RRunner`](com/oracle/truffle/tck/impl/TruffleLanguageRunner.RRunner.md) (class): No description.
- [`TruffleLanguageRunner.RubyRunner`](com/oracle/truffle/tck/impl/TruffleLanguageRunner.RubyRunner.md) (class): No description.
# ▣ com.oracle.truffle.tck
[truffle-tck](index.md) · Every page: [llms.txt](llms.txt)
Package in truffle-tck. Since 0.8 or older.
Contains testing utilities like [`com.oracle.truffle.tck.DebuggerTester`](com/oracle/truffle/tck/DebuggerTester.md) and [`com.oracle.truffle.tck.TruffleRunner`](com/oracle/truffle/tck/TruffleRunner.md).
## Classes
- [`DebuggerTester`](com/oracle/truffle/tck/DebuggerTester.md): Test utility class that makes it easier to test and debug debugger functionality for guest languages.
- [`TruffleRunner`](com/oracle/truffle/tck/TruffleRunner.md): JUnit test runner for unit testing Truffle AST interpreters.
- [`TruffleTestInvokerTruffleTestInvokerLanguageProvider`](com/oracle/truffle/tck/TruffleTestInvokerTruffleTestInvokerLanguageProvider.md): No description.
# ◆ DebuggerTester
[truffle-tck](index.md) › [com.oracle.truffle.tck](com/oracle/truffle/tck/index.md) · Every page: [llms.txt](llms.txt)
Class in [`com.oracle.truffle.tck`](com/oracle/truffle/tck/index.md). Since 0.16.
```java
public final class DebuggerTester implements AutoCloseable
```
Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `DebuggerTester`
Implements: [`AutoCloseable`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AutoCloseable.html)
Test utility class that makes it easier to test and debug debugger functionality for guest languages. Testing suspended callbacks can be cumbersome when having to assert multiple sequential events. The debugger tester allows to test suspended callbacks using sequential code that allows to assert multiple [`events`](https://graalvm.elide.help/25.6.0-elide.4/api/truffle-api/com/oracle/truffle/api/debug/SuspendedEvent.html). It does so by running the engine on a separate thread and it uses internal APIs to allow access to the [`SuspendedEvent`](https://graalvm.elide.help/25.6.0-elide.4/api/truffle-api/com/oracle/truffle/api/debug/SuspendedEvent.html) from another Thread. Do not use this class for anything else than testing.
The debugger tester can print debug traces to standard output with -Dtruffle.debug.trace=true. Example usage:
```java
public void testDebugging() {
try (DebuggerTester tester = new DebuggerTester()) {
// use your guest language source here
Source source = null;
try (DebuggerSession session = tester.startSession()) {
session.suspendNextExecution();
tester.startEval(source);
tester.expectSuspended(new SuspendedCallback() {
@Override
public void onSuspend(SuspendedEvent event) {
// assert suspended event is proper here
event.prepareStepInto(1);
}
});
tester.expectSuspended(new SuspendedCallback() {
@Override
public void onSuspend(SuspendedEvent event) {
// assert another suspended event is proper here
event.prepareContinue();
}
});
// expect no more suspended events
tester.expectDone();
}
}
}
```
## Nested types
- [`DebuggerTester.PositionPredicate`](com/oracle/truffle/tck/DebuggerTester.PositionPredicate.md) (interface): Predicate of testable positions.
## Constructors
### DebuggerTester()
`public DebuggerTester()`. Since 0.16. Constructs a new debugger tester instance. Boots up a new `context` on Thread in the background. The tester instance needs to be `closed` after use. Throws an AssertionError if the engine initialization fails. Cite: `com/oracle/truffle/tck/DebuggerTester.html#()`
### DebuggerTester(Context.Builder)
`public DebuggerTester(Context.Builder contextBuilder)`. Since 0.31. Constructs a new debugger tester instance with a pre-set context builder. Parameters: `contextBuilder` `Context.Builder`: a pre-set context builder. Only out and err streams are set on this builder prior the `Context` instance creation. See also: `DebuggerTester()`. Cite: `com/oracle/truffle/tck/DebuggerTester.html#(org.graalvm.polyglot.Context.Builder)`
### DebuggerTester(Engine, Context.Builder)
`public DebuggerTester(Engine engine, Context.Builder contextBuilder)`. Since 25.0. Constructs a new debugger tester instance with a pre-set context builder and engine. Parameters: `engine` `Engine`: engine to use for the context builder. `contextBuilder` `Context.Builder`: a pre-set context builder. Only out and err streams are set on this builder prior the `Context` instance creation. See also: `DebuggerTester()`. Cite: `com/oracle/truffle/tck/DebuggerTester.html#(org.graalvm.polyglot.Engine,org.graalvm.polyglot.Context.Builder)`
## Methods
### getErr()
`public String getErr()`. Since 0.16. Returns the error output of the underlying `context`. Cite: `com/oracle/truffle/tck/DebuggerTester.html#getErr()`
### getOut()
`public String getOut()`. Since 0.16. Returns the standard output of the underlying `context`. Cite: `com/oracle/truffle/tck/DebuggerTester.html#getOut()`
### getDebugger()
`public Debugger getDebugger()`. Since 0.27. Get the Debugger instance associated with the current engine. Cite: `com/oracle/truffle/tck/DebuggerTester.html#getDebugger()`
### startSession()
`public DebuggerSession startSession()`. Since 0.16. Starts a new [`debugger session`](https://graalvm.elide.help/25.6.0-elide.4/api/truffle-api/com/oracle/truffle/api/debug/Debugger.html#startSession%28com.oracle.truffle.api.debug.SuspendedCallback%29) in the context's `engine`. The debugger session allows to suspend the execution and to install breakpoints. If multiple sessions are created for one `evaluation` then all suspended events are delegated to this debugger tester instance. Returns `DebuggerSession`: a new debugger session. Cite: `com/oracle/truffle/tck/DebuggerTester.html#startSession()`
### startSession(SourceElement...)
`public DebuggerSession startSession(SourceElement... sourceElements)`. Since 0.33. Starts a new [`debugger session`](https://graalvm.elide.help/25.6.0-elide.4/api/truffle-api/com/oracle/truffle/api/debug/Debugger.html#startSession%28com.oracle.truffle.api.debug.SuspendedCallback,com.oracle.truffle.api.debug.SourceElement...%29) in the context's `engine`. The debugger session allows to suspend the execution on the provided source elements and to install breakpoints. If multiple sessions are created for one `evaluation` then all suspended events are delegated to this debugger tester instance. Parameters: `sourceElements` `SourceElement...`: a list of source elements. Returns `DebuggerSession`: a new debugger session. Cite: `com/oracle/truffle/tck/DebuggerTester.html#startSession(com.oracle.truffle.api.debug.SourceElement...)`
### startEval(Source)
`public void startEval(Source s)`. Since 0.27. Starts a new `evaluation` on the background thread. Only one evaluation can be active at a time. Please ensure that `expectDone()` completed successfully before starting a new evaluation. When no source is available please refer to `DebuggerTester.startExecute(Function)`. Throws an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) if another evaluation is still executing or the tester is already closed. Cite: `com/oracle/truffle/tck/DebuggerTester.html#startEval(org.graalvm.polyglot.Source)`
### startExecute(Function)
`public void startExecute(Function script)`. Since 20.0. Starts a new script evaluation on the background thread. Only one evaluation can be active at a time. Please ensure that `expectDone()` completed successfully before starting a new evaluation. If a Source is available please refer to `DebuggerTester.startEval(Source)` . Throws an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) if another evaluation is still executing or the tester is already closed. Cite: `com/oracle/truffle/tck/DebuggerTester.html#startExecute(java.util.function.Function)`
### expectSuspended(SuspendedCallback)
`public void expectSuspended(SuspendedCallback callback)`. Since 0.16. Expects a suspended event and returns it for potential assertions. If the execution completed or was killed instead then an assertion error is thrown. The returned suspended event is only valid until on of `expectKilled()`, `expectSuspended(SuspendedCallback)` or `expectDone()` is called again. Throws an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) if the tester is already closed. Parameters: `callback` `SuspendedCallback`: handler to be called when the execution is suspended. Cite: `com/oracle/truffle/tck/DebuggerTester.html#expectSuspended(com.oracle.truffle.api.debug.SuspendedCallback)`
### expectSuspended(SuspendedCallback, Function)
`public void expectSuspended(SuspendedCallback callback, Function errorVerifier)`. Since 24.1. Expects a suspended event and returns it for potential assertions, allows to verify errors printed to the error output. Parameters: `callback` `SuspendedCallback`: handler to be called when the execution is suspended. `errorVerifier` `Function`: handler, which returns `true` when the error is expected. Cite: `com/oracle/truffle/tck/DebuggerTester.html#expectSuspended(com.oracle.truffle.api.debug.SuspendedCallback,java.util.function.Function)`
### expectThrowable()
`public Throwable expectThrowable()`. Since 0.16. Expects the current evaluation to be completed with an error and not be killed or to produce further suspended events. It returns a string representation of the result value to be asserted. If the evaluation caused any errors they are thrown as [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html). Throws an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) if the tester is already closed. Cite: `com/oracle/truffle/tck/DebuggerTester.html#expectThrowable()`
### expectDone()
`public String expectDone()`. Since 0.16. Expects the current evaluation to be completed successfully and not be killed or to produce further suspended events. It returns a string representation of the result value to be asserted. If the evaluation caused any errors they are thrown as [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html). Throws an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) if the tester is already closed. Cite: `com/oracle/truffle/tck/DebuggerTester.html#expectDone()`
### expectKilled()
`public void expectKilled()`. Since 0.16. Expects the current evaluation to be killed and not be completed or to produce further suspended events. Throws an [`IllegalStateException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html) if the tester is already closed. If the evaluation caused any errors besides the kill exception then they are thrown as [`AssertionError`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html). Cite: `com/oracle/truffle/tck/DebuggerTester.html#expectKilled()`
### getEvalThread()
`public Thread getEvalThread()`. Since 0.16. Returns the thread that the execution started with `startEval(Source)` is running on. Returns `Thread`: the thread instance. Cite: `com/oracle/truffle/tck/DebuggerTester.html#getEvalThread()`
### closeEngine()
`public void closeEngine()`. Since 0.30. Close the engine. It's not possible to evaluate code after engine is closed, use it when the engine needs to be closed before the debugger session. Cite: `com/oracle/truffle/tck/DebuggerTester.html#closeEngine()`
### close()
`public void close()`. Since 0.16. Closes the current debugger tester session and all its associated resources like the background thread. The debugger tester becomes unusable after closing. Overrides `close()`. Cite: `com/oracle/truffle/tck/DebuggerTester.html#close()`
### assertLineBreakpointsResolution(String, String, String)
`public void assertLineBreakpointsResolution(String sourceWithMarks, String resolvedMarkName, String language)`. Since 0.33. Utility method that checks proper resolution of line breakpoints. Breakpoints are submitted to every line of the source and their resolution location is checked. The source need to contain resolution marks in the form of "`R_`" where \ is line number of the original breakpoint position and `R` is the resolved mark name. These marks need to be placed at the proper breakpoint resolution line/column position, for a breakpoint submitted to every line. When several submitted breakpoints resolve to the same position, an interval can be specified in the form of "`R-_`", where both start and end line numbers are inclusive. The marks are stripped off before execution. The guest language code with marks may look like: Parameters: `sourceWithMarks` `String`: a source text, which contains the resolution marks. `resolvedMarkName` `String`: the mark name. It is used in a regular expression, therefore the mark must not have a special meaning in a regular expression. `language` `String`: the source language. Cite: `com/oracle/truffle/tck/DebuggerTester.html#assertLineBreakpointsResolution(java.lang.String,java.lang.String,java.lang.String)`
```java
// test
function test(n) {
if (R1-3_n <= 1) {
return R4_2 * n;
}
return R5-7_n - 1;
}
```
### assertLineBreakpointsResolution(String, DebuggerTester.PositionPredicate, …)
`public void assertLineBreakpointsResolution(String sourceWithMarks, DebuggerTester.PositionPredicate positionPredicate, String resolvedMarkName, String language)`. Since 19.3.0. Parameters: `positionPredicate` `DebuggerTester.PositionPredicate`: `null` to test line breakpoints on all lines, or a predicate that limits the testable lines. See also: `assertLineBreakpointsResolution(java.lang.String, java.lang.String, java.lang.String)`. Cite: `com/oracle/truffle/tck/DebuggerTester.html#assertLineBreakpointsResolution(java.lang.String,com.oracle.truffle.tck.DebuggerTester.PositionPredicate,java.lang.String,java.lang.String)`
### assertColumnBreakpointsResolution(String, String, …)
`public void assertColumnBreakpointsResolution(String sourceWithMarks, String breakpointMarkName, String resolvedMarkName, String language)`. Since 0.33. Utility method that checks proper resolution of column breakpoints. Breakpoints are submitted to marked positions and their resolution location is checked. The source need to contain both breakpoint submission marks in the form of "B\\_" and breakpoint resolution marks in the form of "R\\_" where \ is an identification of the breakpoint. These marks need to be placed at the proper breakpoint submission/resolution line/column position. When several submitted breakpoints resolve to the same position, an interval can be specified in the form of "R\-\\_", where both start and end line numbers are inclusive. The marks are stripped off before execution. The guest language code with marks may look like: Parameters: `sourceWithMarks` `String`: a source text, which contains the resolution marks. `breakpointMarkName` `String`: the breakpoint submission mark name. It is used in a regular expression, therefore the mark must not have a special meaning in a regular expression. `resolvedMarkName` `String`: the resolved mark name. It is used in a regular expression, therefore the mark must not have a special meaning in a regular expression. `language` `String`: the source language. Cite: `com/oracle/truffle/tck/DebuggerTester.html#assertColumnBreakpointsResolution(java.lang.String,java.lang.String,java.lang.String,java.lang.String)`
```java
// B1_test
function B2_test(n) {B3_
if (R1-4_n <= B4_1) {B5_
return R5_2 * n;
}
return R6_n - 1;
B6_}
```
### assertColumnBreakpointsResolution(String, String, …)
`public void assertColumnBreakpointsResolution(String sourceWithMarks, String breakpointMarkName, String resolvedMarkName, String language, URI bpURI)`. Cite: `com/oracle/truffle/tck/DebuggerTester.html#assertColumnBreakpointsResolution(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.net.URI)`
### assertBreakpointsBreakEverywhere(Source)
`public void assertBreakpointsBreakEverywhere(Source source)`. Since 0.33. Utility method that tests if a breakpoint submitted to any location in the source code suspends the execution. A two-pass test is performed. In the first pass, line breakpoints are submitted to every line. In the second pass, breakpoints are submitted to every line and column combination, even outside the source scope. It is expected that the breakpoints resolve to a nearest suspendable location and it is checked that all breakpoints are hit. Parameters: `source` `Source`: a source to evaluate with breakpoints submitted everywhere. Cite: `com/oracle/truffle/tck/DebuggerTester.html#assertBreakpointsBreakEverywhere(org.graalvm.polyglot.Source)`
### assertBreakpointsBreakEverywhere(Source, DebuggerTester.PositionPredicate)
`public void assertBreakpointsBreakEverywhere(Source source, DebuggerTester.PositionPredicate positionPredicate)`. Since 19.3.0. Utility method that tests if a breakpoint submitted to any location permitted by the `PositionPredicate` in the source code suspends the execution. A two-pass test is performed. In the first pass, line breakpoints are submitted to every testable line. In the second pass, breakpoints are submitted to every testable line and column combination, even outside the source scope, if permitted by the `PositionPredicate`. It is expected that the breakpoints resolve to a nearest suspendable location and it is checked that all submitted breakpoints are hit. Parameters: `source` `Source`: a source to evaluate with breakpoints submitted everywhere. `positionPredicate` `DebuggerTester.PositionPredicate`: `null` to submit breakpoints everywhere, or a predicate that limits the testable positions. Cite: `com/oracle/truffle/tck/DebuggerTester.html#assertBreakpointsBreakEverywhere(org.graalvm.polyglot.Source,com.oracle.truffle.tck.DebuggerTester.PositionPredicate)`
### getSourceImpl(Source)
`public static Source getSourceImpl(Source source)`. Since 0.28. Get [`Truffle Source`](https://graalvm.elide.help/25.6.0-elide.4/api/truffle-api/com/oracle/truffle/api/source/Source.html) that corresponds to the `Polyglot Source`. This is a bridge between the two Source implementations. Cite: `com/oracle/truffle/tck/DebuggerTester.html#getSourceImpl(org.graalvm.polyglot.Source)`
## Inherited members
- From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29)
# ◇ DebuggerTester.PositionPredicate
[truffle-tck](index.md) › [com.oracle.truffle.tck](com/oracle/truffle/tck/index.md) · Every page: [llms.txt](llms.txt)
Interface in [`com.oracle.truffle.tck`](com/oracle/truffle/tck/index.md). Since 19.3.0. Nested in [`DebuggerTester`](com/oracle/truffle/tck/DebuggerTester.md).
```java
public interface DebuggerTester.PositionPredicate
```
Predicate of testable positions.
## Methods
### testLine(int)
`boolean testLine(int line)`. Since 19.3.0. Whether to test at the line. Cite: `com/oracle/truffle/tck/DebuggerTester.PositionPredicate.html#testLine(int)`
### testLineColumn(int, int)
`boolean testLineColumn(int line, int column)`. Since 19.3.0. Whether to test at the line and column position. Cite: `com/oracle/truffle/tck/DebuggerTester.PositionPredicate.html#testLineColumn(int,int)`
# ◆ TruffleRunner
[truffle-tck](index.md) › [com.oracle.truffle.tck](com/oracle/truffle/tck/index.md) · Every page: [llms.txt](llms.txt)
Class in [`com.oracle.truffle.tck`](com/oracle/truffle/tck/index.md). Since 0.25.
```java
public class TruffleRunner extends BlockJUnit4ClassRunner
```
Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `Runner` > `ParentRunner` > `BlockJUnit4ClassRunner` > `TruffleRunner`
JUnit test runner for unit testing Truffle AST interpreters.
A test using [`TruffleRunner`](com/oracle/truffle/tck/TruffleRunner.md) consists of 2 parts, a Truffle AST to be tested, and a test method that drives the test, provides input argument values and validates the result.
#### Writing a test AST
The Truffle AST to be tested is written as a [`RootNode`](https://graalvm.elide.help/25.6.0-elide.4/api/truffle-api/com/oracle/truffle/api/nodes/RootNode.html) subclass, for example:
```java
public class TestExecuteNode extends RootNode {
@Child InteropLibrary interop;
public TestExecuteNode() {
super(runWithPolyglot.getTestLanguage());
interop = InteropLibrary.getFactory().createDispatched(5);
}
@Override
public Object execute(VirtualFrame frame) {
Object obj = frame.getArguments()[0];
try {
return interop.execute(obj);
} catch (InteropException ex) {
CompilerDirectives.transferToInterpreter();
Assert.fail(ex.getMessage());
return null;
}
}
}
```
#### Writing a test method
The test method is a normal method annotated with `Test`. It may have one or more arguments of type [`CallTarget`](https://graalvm.elide.help/25.6.0-elide.4/api/truffle-api/com/oracle/truffle/api/CallTarget.html) that are annotated with [`Inject`](com/oracle/truffle/tck/TruffleRunner.Inject.md). The [`Inject`](com/oracle/truffle/tck/TruffleRunner.Inject.md) annotation specifies a [`RootNode`](https://graalvm.elide.help/25.6.0-elide.4/api/truffle-api/com/oracle/truffle/api/nodes/RootNode.html) subclass that is the root of a test AST, and the [`TruffleRunner`](com/oracle/truffle/tck/TruffleRunner.md) will create one [`CallTarget`](https://graalvm.elide.help/25.6.0-elide.4/api/truffle-api/com/oracle/truffle/api/CallTarget.html) for each of these test ASTs. The test method can then execute the AST by calling the [`CallTarget.call`](https://graalvm.elide.help/25.6.0-elide.4/api/truffle-api/com/oracle/truffle/api/CallTarget.html#call%28java.lang.Object...%29) method.
Typically a test method will prepare some arguments, and then do a single call to [`CallTarget.call`](https://graalvm.elide.help/25.6.0-elide.4/api/truffle-api/com/oracle/truffle/api/CallTarget.html#call%28java.lang.Object...%29). Then it should verify the result by inspecting the return value and checking the expected side effects of the test code.
```java
@RunWith(TruffleRunner.class)
public class ExampleTest {
@Test
public void executeTest(@Inject(TestExecuteNode.class) CallTarget target) {
TruffleObject receiver = prepareArgumentValue();
Object ret = target.call(receiver);
Assert.assertEquals(expectedRetValue(), ret);
}
}
```
#### Running a test in the polyglot engine
If a test should be run in the context of a polyglot engine, [`RunWithPolyglotRule`](com/oracle/truffle/tck/TruffleRunner.RunWithPolyglotRule.md) can be used.
```java
@RunWith(TruffleRunner.class)
public static class PolyglotTest {
@ClassRule RunWithPolyglotRule runWithPolyglot = new RunWithPolyglotRule();
private static Object prepared;
@BeforeClass
public void prepare() {
prepared = runWithPolyglot.getTruffleTestEnv().importSymbol("...");
}
@Test
public void executeTest(@Inject(TestExecuteNode.class) CallTarget target) {
Object ret = target.call(prepared);
Assert.assertEquals(expectedRetValue(), ret);
}
}
```
**See also**
- [`warmup iterations and compilation`](com/oracle/truffle/tck/TruffleRunner.Warmup.md)
- [`parameterized Truffle AST tests`](com/oracle/truffle/tck/TruffleRunner.ParametersFactory.md)
## Nested types
- [`TruffleRunner.Inject`](com/oracle/truffle/tck/TruffleRunner.Inject.md) (annotation interface): A parameter annotated with Inject specifies the RootNode of the test AST.
- [`TruffleRunner.ParametersFactory`](com/oracle/truffle/tck/TruffleRunner.ParametersFactory.md) (class): ParametersRunnerFactory for testing Truffle AST interpreters using Parameterized unit tests.
- [`TruffleRunner.RunWithPolyglotRule`](com/oracle/truffle/tck/TruffleRunner.RunWithPolyglotRule.md) (class): JUnit rule to run the tests in the context of a polyglot engine.
- [`TruffleRunner.Warmup`](com/oracle/truffle/tck/TruffleRunner.Warmup.md) (annotation interface): A test method can be annotated with Warmup to specify how many warmup iterations of a test should be done before the Truffle tree is compiled.
## Constructors
### TruffleRunner(Class)
`public TruffleRunner(Class> klass) throws InitializationError`. Since 0.25. Should not be called directly. To use this class, annotate your test class with `@RunWith(TruffleRunner.class)`. See also: `TruffleRunner`. Cite: `com/oracle/truffle/tck/TruffleRunner.html#(java.lang.Class)`
### TruffleRunner(TestClass)
`public TruffleRunner(TestClass testClass) throws InitializationError`. Since 24.2. Should not be called directly. To use this class, annotate your test class with `@RunWith(TruffleRunner.class)`. See also: `TruffleRunner`. Cite: `com/oracle/truffle/tck/TruffleRunner.html#(org.junit.runners.model.TestClass)`
## Methods
### methodInvoker(FrameworkMethod, Object)
`protected final Statement methodInvoker(FrameworkMethod method, Object test)`. Since 0.25. Internal method used by the JUnit framework. Do not call directly. Overrides `methodInvoker(org.junit.runners.model.FrameworkMethod,java.lang.Object)`. Cite: `com/oracle/truffle/tck/TruffleRunner.html#methodInvoker(org.junit.runners.model.FrameworkMethod,java.lang.Object)`
### validateTestMethods(List)
`protected final void validateTestMethods(List errors)`. Since 0.25. Internal method used by the JUnit framework. Do not call directly. Overrides `validateTestMethods(java.util.List)`. Cite: `com/oracle/truffle/tck/TruffleRunner.html#validateTestMethods(java.util.List)`
## Inherited members
- From class `BlockJUnit4ClassRunner`: `collectInitializationErrors`, `computeTestMethods`, `createTest`, `createTest`, `describeChild`, `getChildren`, `getTestRules`, `isIgnored`, `methodBlock`, `possiblyExpectingExceptions`, `rules`, `runChild`, `testName`, `validateConstructor`, `validateFields`, `validateInstanceMethods`, `validateNoNonStaticInnerClass`, `validateOnlyOneConstructor`, `validateZeroArgConstructor`, `withAfters`, `withBefores`, `withPotentialTimeout`
- From class `ParentRunner`: `childrenInvoker`, `classBlock`, `classRules`, `createTestClass`, `filter`, `getDescription`, `getName`, `getRunnerAnnotations`, `getTestClass`, `order`, `run`, `runLeaf`, `setScheduler`, `sort`, `validatePublicVoidNoArgMethods`, `withAfterClasses`, `withBeforeClasses`, `withInterruptIsolation`
- From class `Runner`: `testCount`
- From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29)
# @ TruffleRunner.Inject
[truffle-tck](index.md) › [com.oracle.truffle.tck](com/oracle/truffle/tck/index.md) · Every page: [llms.txt](llms.txt)
Annotation interface in [`com.oracle.truffle.tck`](com/oracle/truffle/tck/index.md). Since 0.25. Nested in [`TruffleRunner`](com/oracle/truffle/tck/TruffleRunner.md).
```java
@Retention(RUNTIME)
@Target({PARAMETER})
public @interface TruffleRunner.Inject
```
A parameter annotated with [`Inject`](com/oracle/truffle/tck/TruffleRunner.Inject.md) specifies the [`RootNode`](https://graalvm.elide.help/25.6.0-elide.4/api/truffle-api/com/oracle/truffle/api/nodes/RootNode.html) of the test AST.
**See also**
- [`TruffleRunner`](com/oracle/truffle/tck/TruffleRunner.md)
## Elements
### value()
`Class extends RootNode> value()`. Since 0.25. Defines the [`root node`](https://graalvm.elide.help/25.6.0-elide.4/api/truffle-api/com/oracle/truffle/api/nodes/RootNode.html) of the Truffle tree that should be tested. Cite: `com/oracle/truffle/tck/TruffleRunner.Inject.html#value()`
# ◆ TruffleRunner.ParametersFactory
[truffle-tck](index.md) › [com.oracle.truffle.tck](com/oracle/truffle/tck/index.md) · Every page: [llms.txt](llms.txt)
Class in [`com.oracle.truffle.tck`](com/oracle/truffle/tck/index.md). Since 0.25. Nested in [`TruffleRunner`](com/oracle/truffle/tck/TruffleRunner.md).
```java
public static final class TruffleRunner.ParametersFactory implements ParametersRunnerFactory
```
Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `ParametersFactory`
Implements: `ParametersRunnerFactory`
`ParametersRunnerFactory` for testing Truffle AST interpreters using `Parameterized` unit tests. To use the parameters for constructing the test AST, the test [`RootNode`](https://graalvm.elide.help/25.6.0-elide.4/api/truffle-api/com/oracle/truffle/api/nodes/RootNode.html) constructor may take the test class as single argument, or alternatively the test [`RootNode`](https://graalvm.elide.help/25.6.0-elide.4/api/truffle-api/com/oracle/truffle/api/nodes/RootNode.html) can be a non-static inner class of the test class.
```java
@RunWith(Parameterized.class)
@UseParametersRunnerFactory(TruffleRunner.ParametersFactory.class)
public static class ParameterizedTest {
@Parameters(name = "{0}, {1}")
public static Collection