AgentSkillsCN

write-unit-test-for-query-builder

为一个定义了 RDF4J 查询的 Scala 对象编写单元测试。当用户提出“为查询编写单元测试”时,本技能即可触发。

SKILL.md
--- frontmatter
name: write-unit-test-for-query-builder
description: "Create a unit test for a Scala object that defines an RDF4J query. Triggers on: write unit test for query"
user-invocable: true
argument-hint: [object-name]

Create Unit Test for RDF4J Query Object

Create a unit test for the Scala object $1. The object contains at least one public function producing a query written using the rdf4j library. Analyze these functions and create the necessary test cases that verify the generated query strings are correct. Take a look at existing *Query.scala and their corresponding test for reference.

The unit test must be written in zio-test. When asserting the query string generated by the object compare the entire String. The assertTrue should use a formatted string for better readability, like this:

scala
val actual: String = ???
assertTrue(actual == 
  """PREFIX ex: <http://example.org/>
    |SELECT ?s ?p ?o
    |WHERE {
    |  ?s ?p ?o .
    |}""".stripMargin)

After you have written the test run it and verify it succeeds.