GithubHelp home page GithubHelp logo

isabella232 / conformance-tests Goto Github PK

View Code? Open in Web Editor NEW

This project forked from googleapis/conformance-tests

0.0 0.0 0.0 170 KB

GoogleAPIs client library conformance tests

License: Apache License 2.0

Shell 45.39% Go 54.61%

conformance-tests's Introduction

Google APIs Conformance Tests

This repository is used to host a collection of conformance tests for Google API client libraries. Conformance tests are mainly used by Google APIs Github Organization repositories for language client libraries.

Conformance Test Specification

While some per-API, per-language work will always be required for consuming the conformance tests, this can be minimized by each API abiding by the same conventions:

  • Each API's tests are entirely within a directory of the form {api-name}/{api-version}. Example: storage/v1
  • A .proto file specifies the format of the test cases. Example: Firestore tests
  • Test cases are specified as a set of inputs and expected outputs, and are defined in .json files. Example: Firestore test case

Proto conventions

The test protos should live in a subdirectory hierarchy beginning with proto within the API-specific directory. Further subdirectories should reflect the proto package name of the tests, which should start with google.cloud.conformance and reflect the API name and version. For example, the Firestore v1 test protos are in the google.cloud.conformance.firestore.v1 proto package, and are in a directory of firestore/v1/proto/google/cloud/conformance/firestore/v1.

Note: while the directory structure here ends up being very deep, it means we follow the proto convention, which makes importing protos from each other simpler.

The test protos may refer to protos within the production API. There is no versioning applied to these imports; it's assumed that it's always sufficient to take the head of the master branch in https://github.com/googleapis/googleapis.

Each API should have a TestFile message containing repeated fields of specific test types, such as ReadTest and WriteTest. This allows for extensibility as further tests are developed.

Each specific test message should have a description field of type string. When running tests, these should be used as reported test names.

JSON conventions

Each JSON file in the API directory should be the JSON representation of a TestFile message. Conceptually, each JSON file is parsed as a TestFile, then all the TestFile messages are merged together to form a single TestFile containing all the tests.

This provides flexibility for the test author, in terms of how the tests are spread across files. Strategies include:

  • One JSON file per test
  • One JSON file per feature
  • One single JSON file for all tests

This approach still leaves consumers in a simple situation:

  • Common code can be written to read all files to produce a complete test suite
  • Each file can be validated as a TestFile, making the validation code simple

Each test should have a populated description field with a value which is unique within that API.

Validator

Each set of tests should come with a validator to ensure that the JSON files conform with the proto specification. The validator should be written in Go in the API-specific directory, in a file called validator.go. This should be invoked from the .kokoro/validator.sh script which is executed as part of continuous integration.

In most cases you don't need to know Go in order to write a validator: simply copy an existing validator and edit it to reflect the name and version of the API you're writing tests for.

Consuming tests

Conformance test runners must be implemented per language, per client (for clients that have conformance tests defined here). These runners must do the minimal work to translate a conformance test specified here into a testcase that inputs the given input data and asserts based on the given assertion.

Generally, conformance tests are accessed as git submodules in the repositories. However, copy-pasting the tests may also be a reasonable approach, though it is prone to scalability and maintainability issues.

conformance-tests's People

Contributors

frankyn avatar jskeet avatar benwhitehead avatar jeanbza avatar jkwlui avatar dopiera avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.