NeoA11y / SpeakTouch

[WIP] A free software screen reader for Android.
9 stars 0 forks source link

Add local tests to project #129

Closed Irineu333 closed 11 months ago

Irineu333 commented 11 months ago

Description

The implementation of tests is crucial to prevent regressions and accelerate development. This pull request represents a significant step towards full test coverage in Speak Touch.

Given that the SpeakTouch code intensely interacts with the Android framework APIs, local tests isolated from the Android framework are not viable. One option would be to simulate these structures with Mockito or Mockk. However, although valid, this approach requires the developer to code the simulated structures, which will most likely not reflect the actual behavior, but rather the developer's expectations. Therefore, I opted to use Robolectric to simulate the Android framework locally. This approach seems more effective and aligned with the application's real behavior. My experience with Robolectric was surprisingly positive, especially due to the ease of creating tests with it

Improvements

Irineu333 commented 11 months ago

@coderabbitai review

coderabbitai[bot] commented 11 months ago

Walkthrough

The project's testing configuration has been overhauled, particularly for Android unit testing. The update includes a new Gradle run configuration for metadata, improvements to build scripts, and the introduction of custom view tests. Notably, there's a shift from instrumented tests to local unit tests with Robolectric, as seen in the build.gradle.kts and test classes.

Changes

File Path Change Summary
.idea/runConfigurations/... Added "Update metadata" Gradle run configuration.
app/build.gradle.kts Removed testInstrumentationRunner, added testOptions, updated buildTypes, and switched to testImplementation.
app/src/test/java/com/.../TypeTest.kt Added tests for UI element type identification.
app/src/test/java/com/.../CustomCheckable.kt Created a custom checkable view class with accessibility.
app/src/test/java/com/.../CustomList.kt Created a custom list view class with specialized accessibility.
test/build.gradle.kts Removed testInstrumentationRunner and test-related dependencies.

Poem

In the burrow of code, a change does leap, Tests now run where the Robolectric peep. With views so custom, they check with care, 🐇 A rabbit's touch, with flair to spare. 🎩✨

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on X ?


Tips ### Chat with CodeRabbit Bot (`@coderabbitai`) - You can reply to a review comment made by CodeRabbit. - You can tag CodeRabbit on specific lines of code or files in the PR by tagging `@coderabbitai` in a comment. - You can tag `@coderabbitai` in a PR comment and ask one-off questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions. ### CodeRabbit Commands (invoked as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger a review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - The JSON schema for the configuration file is available [here](https://coderabbit.ai/integrations/coderabbit-overrides.v2.json). - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json`
Irineu333 commented 11 months ago

@PatrykMis I'm testing CodeRabbit on the project, do you like it? It's a free AI code review tool for open source projects.

PatrykMis commented 11 months ago

@Irineu333 it's a great tool which, as I see, summarizes changes made in pull requests, it is also capable to see them in context of linked issues.

And what about integrating SonarCloud?

Irineu333 commented 11 months ago

I was a bit disappointed with the CodeRabbit. I thought it could point out potential problems in the code like a reviewer, but the comments are very generic (see #128). In this PR, it just summarized the changes.

Regarding SonarCloud, I will study it.