Skip to content

Commit a3e53f6

Browse files
committed
Update information about tests in scala3doc readme
1 parent a8cff71 commit a3e53f6

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

scala3doc/README.md

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,36 @@ You can also find the result of building the same sites for latest `master` at:
7272

7373
### Testing
7474

75-
Most tests rely on comparing signatures (of classes, methods, objects etc.) extracted from the generated documentation
76-
to signatures found in source files. Such tests are defined using [MultipleFileTest](src/test/scala/dotty/dokka/MultipleFileTest.scala) class
77-
and its subtypes (such as [SingleFileTest](src/test/scala/dotty/dokka/SingleFileTest.scala))
78-
79-
WARNING: As the classes mentioned above are likely to evolve, the description below might easily get out of date.
80-
In case of any discrepancies rely on the source files instead.
81-
82-
`MultipleFileTest` requires that you specify the names of the files used to extract signatures,
83-
the names of directories containing corresponding TASTY files
84-
and the kinds of signatures from source files (corresponding to keywords used to declare them like `def`, `class`, `object` etc.)
85-
whose presence in the generated documentation will be checked (other signatures, when missing, will be ignored).
86-
The mentioned source files should be located directly inside `src/main/scala/tests` directory
87-
but the file names passed as parameters should contain neither this path prefix nor `.scala` suffix.
88-
The TASTY folders are expected to be located in `target/${dottyVersion}/classes/tests` (after successful compilation of the project)
89-
and similarly only their names relative to this path should be provided as tests' parameters.
90-
For `SingleFileTest` the name of the source file and the TASTY folder are expected to be the same.
75+
To implement integration tests that inspects state of the model on different stages of
76+
documentation generation one can use [ScaladocTest](src/test/scala/dotty/dokka/ScaladocTest.scala#L15).
77+
This class requires providing the name of the test and a the list of assertions.
78+
79+
Name of the test is used to extract symbols that should be included in given test run from
80+
the TASTY files. All test data is located in [scala3doc-testcases module](../scala3doc-testcases/src).
81+
It is compiled together with the rest of modules. This solves lots of potential problems with
82+
invoking the compiler in a separate process such as mismatching versions. Every test is using
83+
only symbols defined in the package with the same name as the test located inside top level `tests`
84+
package (including subpackages). This restriction may be relaxed in the future.
85+
86+
Assertions of each test are defined as list of [Assertion enum](src/test/scala/dotty/dokka/ScaladocTest.scala#L63)
87+
instances. Each of them represents a callback that is invoked in corresponding phase of
88+
documentation generation. Those callback can inspect the model, log information and raise errors
89+
using `reportError` method.
90+
91+
#### Signature tests
92+
93+
Some of the tests rely on comparing signatures (of classes, methods, objects etc.) extracted from
94+
the generated documentation to signatures found in source files. Such tests are defined using
95+
[SignatureTest](src/test/scala/dotty/dokka/SignatureTest.scala#L16) class, that is a subclass of
96+
`ScaladocTest` and uses exactly tha same mechanism to find input symbols in the TASTY files.
97+
98+
Signature tests by default assume that sources that were used to generate used TASTY files are
99+
located in the file with the same name as the name of the test. If this is not the case optional
100+
parameter `sourceFiles` can be used to pass list of source file names (without `.scala` extension).
101+
102+
Those tests also requires specifying kinds of ignatures from source files (corresponding to
103+
keywords used to declare them like `def`, `class`, `object` etc.) whose presence in the generated
104+
documentation will be checked (other signatures, when missing, will be ignored).
91105

92106
By default it's expected that all signatures from the source files will be present in the documentation
93107
but not vice versa (because the documentation can contain also inherited signatures).

0 commit comments

Comments
 (0)