Skip to content

Data-driven testing #51

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
echeran opened this issue Apr 21, 2020 · 3 comments
Open

Data-driven testing #51

echeran opened this issue Apr 21, 2020 · 3 comments
Assignees
Labels
A-design Area: Architecture or design C-test-infra Component: Integration test infrastructure S-epic Size: Major project (create smaller child issues) T-core Type: Required functionality

Comments

@echeran
Copy link
Contributor

echeran commented Apr 21, 2020

One part of the larger testing strategy for ICU4X would be to have a clean, consistent way of organizing the unit tests for the business logic (i18n algorithms). In particular, it would be nice to have a data-oriented style of testing, as exemplified already in some parts of @zbraniecki's unic-locale repo. ICU unit tests tend to be written in a parameterized style, but the idea here is to take the data-driven nature further.

Pros and Cons

Pros:

  • ICU algorithms are mostly (all?) stateless, so describing in terms of data condenses test code to essential inputs and outputs
  • Using a data representation makes tests language agnostic and reusable in target languages
  • Representing tests as data would mirror the essence of user inputs and outputs described in the wrapping layer
  • A concise notation would incentivize uniformity and concision of testing

Cons:

  • Need to create a test harness/mini-framework to parse and execute test cases written as data
  • Target languages wanting to reuse tests-as-data on ICU4X client libraries would need to write a native harness/mini-framework
  • Tests that depend on stateful resources (ex: data stores) with setup/teardown phases would have to be handled in some other way
  • Representing tests in a new way would require some initial adjustment

Existing libraries

Most searches for "data driven testing" produce results for databases, spreadsheets, and automated web UI testing. Links to more relevant pre-existing libraries are welcome.

Some examples of test libraries written to reduce the cognitive load when testing, especially when testing data collections:

  • Truth - Fluent assertions for Java and Android
  • Expectations - error messages that do a nested data diff on expected vs. actual

Testing features

Beyond just asserting that the actual return value matches the provided expected value, we should also consider the following testing aspects:

  • matching functions/operators (equal, not equal, contains, does not contain, equal contents in {any, same} order, ...)
  • test name
  • test type (corresponding to ICU4X feature)
  • message on error
  • expected failure modes (ex: exceptions/panics)
  • parameterization (single test input vs. list of related test inputs)
  • APIs to read/construct test cases (ex: to enable interop with fuzz testing?)
@sffc sffc added the C-test-infra Component: Integration test infrastructure label Apr 21, 2020
@sffc sffc added T-core Type: Required functionality A-design Area: Architecture or design labels May 7, 2020
@nciric
Copy link
Contributor

nciric commented May 15, 2020

Since we play a lot with JSON (test data etc) - this may be helpful - JSON Schema.

JSON Schema

  • Describes your existing data format(s).
  • Provides clear human- and machine- readable documentation.
  • Validates data which is useful for:
    • Automated testing.
    • Ensuring quality of client submitted data.

@sffc sffc added this to the 2020 Q2 milestone Jun 17, 2020
@sffc sffc modified the milestones: 2020 Q2, 2020 Q3 Jul 23, 2020
@sffc sffc modified the milestones: 2020 Q3, 2020 Q4 Oct 22, 2020
@sffc sffc modified the milestones: 2020 Q4, 2021-Q1-m1 Jan 7, 2021
@sffc sffc assigned sffc and unassigned echeran Feb 4, 2021
@sffc sffc modified the milestones: 2021-Q1-m1, ICU4X 0.2 Feb 4, 2021
@sffc sffc removed this from the ICU4X 0.2 milestone Mar 25, 2021
@sffc
Copy link
Member

sffc commented Apr 3, 2021

I'm merging #223 and #410 into this issue. Some notes from those issues:

  • We want the data to come through the data provider, but we also want data that lives close to the test. Can we maybe put invariant (und) data in the test file and load resources for other locales?
  • Is there a way to make the test data extensible by users?

@sffc sffc mentioned this issue Apr 3, 2021
@sffc sffc added the S-epic Size: Major project (create smaller child issues) label Apr 3, 2021
@sffc
Copy link
Member

sffc commented Oct 19, 2021

@sffc sffc assigned gnrunge and unassigned sffc Apr 1, 2022
@sffc sffc added this to the ICU4X 1.1 milestone Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-design Area: Architecture or design C-test-infra Component: Integration test infrastructure S-epic Size: Major project (create smaller child issues) T-core Type: Required functionality
Projects
None yet
Development

No branches or pull requests

4 participants