cqframework / cql-tests-runner

Test Runner for CQL Tests
Apache License 2.0
3 stars 1 forks source link

Implement Option to Rerun Failed or Errored Tests in CQL Test Runner #12

Open darkknight13 opened 1 month ago

darkknight13 commented 1 month ago

This enhancement proposes adding functionality to the CQL Test Runner to rerun tests that have failed or encountered errors. This feature would enable developers to focus on retesting specific cases after addressing issues in their CQL engine. Presently, tests are executed sequentially for all cases without the ability to selectively rerun failed tests.

darkknight13 commented 2 weeks ago

To rerun tests based on their status, I've planned to cache them in the file system and load them accordingly. For this purpose, I intend to encapsulate the tests within the following CQLTest class.

/**
 * Represents a CQL Test.
 */
class CQLTest {
    /**
     * Enum representing possible test statuses.
     * @enum {string}
     */
    static STATUS = {
        'PASS': 'pass',
        'FAIL': 'fail',
        'SKIP': 'skip',
        'ERROR': 'error',
    }

    /**
     * Creates an instance of CQLTest.
     * @param {string} tests - The type of test.
     * @param {string} group - The group of test.
     * @param {object} test - The test details.
     */
    constructor(tests, group, test) { }

    /**
     * Saves the test configuration to a file.
     * @param {string} directory - The directory to save the file.
     * @param {boolean} [force=false] - Whether to force saving even if the file already exists.
     * @returns {string|null} - The file save path, or null if directory is not provided.
     */
    save(directory, force = false) { }

    /**
     * Runs the test.
     * @param {string} apiUrl - The API URL to run the test against.
     * @returns {Promise<CQLTestResult>} - The result of the test.
     */
    async run(apiUrl) { }

    /**
     * Returns the JSON representation of the test.
     * @returns {object} - The JSON representation of the test.
     */
    toJSON() { }

    /**
     * Creates a CQLTest instance from a JSON configuration.
     * @param {object} config - The JSON configuration.
     * @returns {CQLTest} - The CQLTest instance.
     */
    static fromJSON(config) { }
}