@@ -53,6 +53,110 @@ parent modules), say `M`, such that `M.runtests(...)` is equivalent to
53
53
calling ` retest(M, ...) ` .
54
54
55
55
56
+ ## Quick start
57
+
58
+ Both ` ReTest ` and ` InlineTest ` are registered packages and can be installed
59
+ the usual way. Let's create a package ` MyPackage ` , which is initially a
60
+ single file located in a directory known to ` LOAD_PATH ` . We want to test
61
+ its ` greet ` function, by writing tests directly in the same file;
62
+ this is a use-case for ` InlineTest ` , which loads faster than ` ReTest ` :
63
+ ``` julia
64
+ # MyPackage.jl file
65
+
66
+ module MyPackage
67
+ using InlineTest
68
+
69
+ greet () = " Hello World!"
70
+
71
+ @testset " greet" begin
72
+ @test greet () == " Hello World!"
73
+ end
74
+
75
+ end # module
76
+ ```
77
+
78
+ Now, in a Julia session, we load ` MyPackage ` and ` ReTest ` (needed to actually
79
+ run the tests):
80
+ ``` julia
81
+ julia> using MyPackage, ReTest
82
+
83
+ julia> MyPackage. runtests ()
84
+ Pass
85
+ MyPackage:
86
+ greet | 1
87
+ ```
88
+
89
+ Suppose now that we organize ` MyPackage ` as a standard package, with
90
+ a proper "runtests.jl" file. We can still keep testsets within "MyPackage.jl",
91
+ while adding more thorough tests in the "test" folder, which can contain
92
+ two files, "runtests.jl" and "MyPackageTests.jl":
93
+ ``` julia
94
+ # MyPackage/test/runtests.jl file
95
+
96
+ using ReTest, MyPackage
97
+ include (" MyPackageTests.jl" )
98
+
99
+ # when including this file (e.g. with `Pkg.test`), all the tests
100
+ # in both modules will be run:
101
+
102
+ retest (MyPackage, MyPackageTests)
103
+ ```
104
+
105
+ ``` julia
106
+ # MyPackage/test/MyPackageTests.jl file
107
+
108
+ module MyPackageTests
109
+ using MyPackage, ReTest
110
+
111
+ @testset " more greet" begin
112
+ @testset " concatenation" begin
113
+ @test MyPackage. greet ()^ 2 == " Hello World!Hello World!"
114
+ end
115
+ end
116
+
117
+ @testset " stuff" begin
118
+ @test true
119
+ end
120
+
121
+ end # module
122
+ ```
123
+
124
+ We can now load tests either via ` using MyPackageTests ` , if ` LOAD_PATH ` is configured
125
+ appropriately, or via ` include ` , and run whichever tests we want:
126
+ ``` julia
127
+ julia> include (" test/MyPackageTests.jl" );
128
+
129
+ julia> using ReTest # to use the `retest` function
130
+
131
+ julia> retest (dry= true , verbose= 2 ) # just list tests, showing nested ones
132
+ MyPackage
133
+ 1 | greet
134
+
135
+ Main. MyPackageTests
136
+ 1 | more greet
137
+ 2 | concatenation
138
+ 3 | stuff
139
+
140
+ julia> retest (" greet" , verbose= 2 ) # run only tests related to `greet()`
141
+ Pass
142
+ MyPackage:
143
+ greet | 1
144
+
145
+ Main. MyPackageTests:
146
+ more greet | 1
147
+ concatenation | 1
148
+
149
+ Overall | 2
150
+
151
+ julia> MyPackageTests. runtests (3 ) # run only testset with ID 3 in MyPackageTests
152
+ Pass
153
+ Main. MyPackageTests:
154
+ 3 | stuff | 1
155
+ ```
156
+
157
+ Here it is for basic usage!
158
+
159
+
56
160
## API
57
161
58
162
``` @meta
0 commit comments