# 测试模板

`@TestTemplate`方法不是常规的测试用例，而是测试用例的模板。为此，它被设计成根据已注册的提供者返回的调用上下文的数量被调用多次。因此，它必须与注册的`TestTemplateInvocationContextProvider`扩展一起使用。测试模板方法的每次调用都像执行常规`@Test`方法一样，完全支持相同的生命周期回调和扩展。有关使用示例，请参阅[为测试模板提供调用上下文](/junit5/index/index-4/test-templates.md)。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doczhcn.gitbook.io/junit5/index/index-2/test-templates.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
