-
Notifications
You must be signed in to change notification settings - Fork 133
Add documentation on automated testing for extensions #480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SoryRawyer
wants to merge
3
commits into
master
Choose a base branch
from
extension-testing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -343,3 +343,27 @@ Packages.com.google.refine.expr.MetaParser.registerLanguageParser( | |||||
|
|
||||||
| The first string is the prefix that gets prepended to each expression so that we know which language the expression is in. This should be short, unique, and identifying. The second string is a user-friendly name of the language. The third is an object that implements the interface `com.google.refine.expr.LanguageSpecificParser`. The final string is the default expression in that language that would return the cell's value. | ||||||
|
|
||||||
| ## Testing | ||||||
|
|
||||||
| Like OpenRefine core, extensions can test backend code through Java unit tests and frontend/integration tests can be written using Cypress. In addition to the resources below, extension authors are encouraged to review the documentation related to [functional tests](/docs/technical-reference/functional-tests) in OpenRefine core. | ||||||
|
|
||||||
| Please note that Java unit tests can be run from the command line with no additional setup, but integration tests need to have a running instance of OpenRefine to test against. | ||||||
|
|
||||||
| ### Java unit testing | ||||||
| The sample extension template includes a reference unit test suite which leverages [the `RefineTest` base class](https://github.com/OpenRefine/OpenRefine/blob/master/modules/core/src/test/java/com/google/refine/RefineTest.java) provided by OpenRefine core. Tests are not required to extend `RefineTest`, but that class provides many utilities that may help you test your extension. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ### End to end testing in Cypress | ||||||
| OpenRefine uses [Cypress](https://www.cypress.io/) to automate frontend and integration testing. To get started with end-to-end testing, [this guide in the Cypress docs](https://docs.cypress.io/app/end-to-end-testing/writing-your-first-end-to-end-test) may be helpful. The [documentation for OpenRefine's functional tests](/docs/technical-reference/functional-tests) also provides guidance for writing Cypress tests. For reference, please see the [Cypress tests in OpenRefine core](https://github.com/OpenRefine/OpenRefine/tree/master/main/tests/cypress) and the [Cypress tests in CommonsExtension](https://github.com/OpenRefine/CommonsExtension/tree/master/cypress). | ||||||
|
|
||||||
| When running Cypress tests, it is important to remember that the instance of OpenRefine being tested must have the [extension installed](/docs/manual/installing#installing-extensions). The `REFINE_DATA_DIR` environment variable is a helpful way of configuring the location of your extensions. | ||||||
|
|
||||||
| Cypress can also be run in headless mode, enabling end-to-end tests in CI/CD pipelines. The documentation for this feature can be found [on the Cypress website](https://docs.cypress.io/app/continuous-integration/overview) and an example script for running end-to-end tests can be found in [the `refine` shell script](https://github.com/OpenRefine/OpenRefine/blob/master/refine#L364-L443). | ||||||
|
|
||||||
| #### Testing OpenRefine with your extension installed | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SoryRawyer do you want to add here more details following your recent work? |
||||||
| Even without a dedicated test suite for the extension, Cypress tests can aid extension developers. The same setup above allows extension developers to run the core OpenRefine Cypress suite. This allows extension developers to confirm that their extension does not interfere with any core OpenRefine operations. Once again, install your extension in a dedicated test directory and start OpenRefine using that directory like so: | ||||||
| ``` | ||||||
| # note: your extension should be in a directory called "extensions" within this directory | ||||||
| REFINE_DATA_DIR=/path/to/your/test/directory ./refine | ||||||
| ``` | ||||||
|
|
||||||
| The Cypress tests can be run by following the remaining steps in the [functional tests documentation](/docs/technical-reference/functional-tests) and will now run against an OpenRefine instance that has your extension installed. | ||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.