Kotest 컴파일러 매처(Compiler Matchers)
컴파일러 매처에 대해서 설명한다.
	kotest-assertions-compiler 확장은 지정된 kotlin 코드 조각이 컴파일되는지 여부를 확인하는 매처를 제공한다. 이 확장은 kotlin-compile-testing에 대한 래퍼이며 다음과 같은 매처를 제공한다.
- String.shouldCompile()
- String.shouldNotCompile()
- File.shouldCompile()
- File.shouldNotCompile()
컴파일 매처를 추가하려면 프로젝트에 다음 종속성을 추가한다.
testImplementation("io.kotest.extensions:kotest-assertions-compiler:${version}")
작성법:
class CompilationTest: StringSpec() {
    init {
        "shouldCompile test" {
            val codeSnippet = """ val aString: String = "A valid assignment" """.trimMargin()
            codeSnippet.shouldCompile()
            File("SourceFile.kt").shouldCompile()
        }
        "shouldNotCompile test" {
            val codeSnippet = """ val aInteger: Int = "A invalid assignment" """.trimMargin()
            codeSnippet.shouldNotCompile()
            File("SourceFile.kt").shouldNotCompile()
        }
    }
}
코드 조각 컴파일을 검사하는 동안 호출 프로세스의 클래스 경로가 상속되므로 호출 프로세스에서 사용 가능한 모든 종속성은 코드 조각을 컴파일하는 동안에도 사용할 수 있다.
지정된 Kotlin 코드가 컴파일되는지 여부를 확인하는 매처
| 매처 | 설명 | 
|---|---|
| string.shouldCompile() | 문자열이 유효한 Kotlin 코드인지 확인한다. | 
| file.shouldCompile() | 파일에 유효한 Kotlin 코드가 포함되어 있는지 확인한다. |