//arrow-meta-test/arrow.meta.plugin.testing/assertThis

assertThis

[jvm]
fun assertThis(compilerTest: CompilerTest)

Allows checking if a compiler plugin is working as expected.

It’s not necessary to write assertions with actual and expected behavior. Assertions will be built automatically from simply indicating the expected behavior in a CompilerTest.

Running the compilation from the provided configuration and getting the results (status, classes, and output messages) is possible thanks to Kotlin Compile Testing, a library developed by Thilo Schuchort, and forked by ZacSweers.

Main schema:

assertThis(
    CompilerTest(
      config = { ... },
      code = { ... },
      assert = { ... }
    )
)

Compilation will be executed with the provided configuration (config) and code snippets (code). Then, the expected behavior (assert) will be checked.

For instance:

assertThis(
    CompilerTest(
      config = { metaDependencies },
      code = { "...".source },
      assert = {
        quoteOutputMatches("...".source) +
        "...".source.evalsTo(someValue)
      }
    )
)

Parameters

jvm

   
compilerTest necessary data to run the compilation, source code to be compiled and expected behavior

See also

 
CompilerTest

Do you like Arrow?

Arrow Org
<