You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
Pavel Shishkin e90dcb5c89
update compose compiler version to 1.5.13.2/1.5.13.3 (#4798)
7 months ago
..
buildSrc Refactor composable-test-cases to get rid of dependency on compose-multiplatform-gradle-plugin (#4421) 9 months ago
common Refactor composable-test-cases to get rid of dependency on compose-multiplatform-gradle-plugin (#4421) 9 months ago
gradle Update Kotlin and Compose in composable-test-cases (#4046) 11 months ago
testcases Update compose compiler version to 1.5.10.2 (#4652) 7 months ago
.gitignore Add composable-test-cases project to check JB compose compiler for all targets (#2751) 2 years ago
README.MD Add composable-test-cases project to check JB compose compiler for all targets (#2751) 2 years ago
build.gradle.kts Refactor composable-test-cases to get rid of dependency on compose-multiplatform-gradle-plugin (#4421) 9 months ago
gradle.properties update compose compiler version to 1.5.13.2/1.5.13.3 (#4798) 7 months ago
gradlew Add composable-test-cases project to check JB compose compiler for all targets (#2751) 2 years ago
gradlew.bat Add composable-test-cases project to check JB compose compiler for all targets (#2751) 2 years ago
settings.gradle.kts Refactor composable-test-cases to get rid of dependency on compose-multiplatform-gradle-plugin (#4421) 9 months ago

README.MD

Run:

./gradlew build -Pcompose.kotlinCompilerPluginVersion=1.4.2-rc03 -Pkotlin.version=1.8.10 to build and run the tests,

or ./gradlew allTests -Pcompose.kotlinCompilerPluginVersion=1.4.2-rc03 -Pkotlin.version=1.8.10 to only run the tests.

It will build and run the tests for all available targets (depends on a host machine). See TargetsConfiguration to update the targets.

Test cases

Directory: ./testcases

Every test case contains a simple project with 2 or more modules with applied Compose plugin. The goal of such a project is to check a specific case of Composable usage.
A test case ensures that the code compiles and behaves as expected when running.
A test case contains 2 or more modules to check crossmodule compilation (the test dependencies should be placed in a ...-lib module).

See a test case template for an example. Splitting the test cases into separate small projects helps in distinguishing the potential compilation bugs.

The behaviour is checked by the tests in a ...-main module of a test case.
The tests create a simple text Composition and then compares the text dump with an expected value.
Example:

@Test
fun testExample2() = runTest {
    val root = composeText {
        TextLeafNode("Leaf")
        TextContainerNode("node") {
            TextLeafNode("child1")
            TextLeafNode("child2")
            TextLeafNode("child3")
        }
    }

    assertEquals("root:{Leaf, node:{child1, child2, child3}}", root.dump())
}

The API for the text Composition is implemented in the common module. More test examples (including recomposition cases) can be found here.

To add a new test case:

  • Use /testcases/template as a starting point (copy it and rename). Place a new testcase in /testcases folder.
  • Add new modules in settings.gradle.kts
  • Please follow the naming convention for modules. Their names should end with -lib or -main.
    We need 2 modules (...-lib and ...-main) to test crossmodule compilation.
    Place the test dependencies in a ...-lib module.