@@ -31,22 +31,50 @@ The test generator will remove any test cases that are marked as excluded (`incl
3131Some exercises might need some tweaks before rendering the data.
3232For example, you might want to make the description less verbose.
3333
34- To tweak the test cases, define a ` .meta/generator.clj ` file with a ` <slug>-generator ` namespace .
35- Then, define a function called ` transform ` that takes a single argument — the parsed test cases — and returns the transformed test cases.
34+ To tweak test cases, define a ` .meta/generator.clj ` file with a ` <slug>-generator ` namespace.
35+ There are two ways in which you can transform test cases:
3636
37- Example:
37+ - Update test case(s)
38+ - Add/remove test case(s)
39+
40+ #### Update test case(s)
41+
42+ To update individual test cases, define the following function:
43+
44+ ``` clojure
45+ (defn- transform-test-case
46+ " Update a test case"
47+ [test-case]
48+ ; ; function body
49+ )
50+ ```
51+
52+ ##### Example
53+
54+ This example removes all but the last element of the ` :path ` value (shortening the description):
3855
3956``` clojure
4057(ns difference-of-squares-generator )
4158
42- (defn- update-path [path]
43- (take-last 1 path))
59+ (defn- transform-test-case [test-case]
60+ (update test-case :path #(take-last 1 %)))
61+ ```
62+
63+ #### Add or remove test case(s)
4464
45- (defn transform [test-cases]
46- (map #(update % :path update-path) test-cases))
65+ To update individual test cases, define the following function:
66+
67+ ``` clojure
68+ (defn- transform-test-cases
69+ " Add/remove test case(s)"
70+ [test-cases]
71+ ; ; function body
72+ )
4773```
4874
49- This step is entirely optional.
75+ ``` exercism/note
76+ If you define _both_ functions, `transform-test-cases` is called first and `transform-test-case` second.
77+ ```
5078
5179### Step 4: render the test cases
5280
0 commit comments