diff --git a/CHANGELOG.md b/CHANGELOG.md index 998ec9a7..1b7280ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +## [3.7.0] - 2021-08-21 + +Feature Added: CppUTest Framework Support with tests + ## [3.6.27] - 2021-08-09 NPM update diff --git a/README.md b/README.md index 495ddf63..94575b03 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # C++ TestMate -## A **Catch2**, **GoogleTest**, **doctest** and **GoogleBenchmark** Explorer for VSCode +## A **Catch2**, **GoogleTest**, **CppUTest**, **doctest** and **GoogleBenchmark** Explorer for VSCode [![Visual Studio Marketplace](https://img.shields.io/vscode-marketplace/v/matepek.vscode-catch2-test-adapter.svg)](https://marketplace.visualstudio.com/items?itemName=matepek.vscode-catch2-test-adapter) [![GitHub issues](https://img.shields.io/github/issues/matepek/vscode-catch2-test-adapter?color=green)](https://github.com/matepek/vscode-catch2-test-adapter/issues) @@ -8,8 +8,7 @@ [![Gitter](https://badges.gitter.im/CppTestMate/community.svg)](https://gitter.im/CppTestMate/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) This extension allows you to run your [Catch2](https://github.com/catchorg/Catch2), -[Google Test](https://github.com/google/googletest) -and [DOCtest](https://github.com/onqtam/doctest) +[Google Test](https://github.com/google/googletest), [CppUTest](https://github.com/cpputest/cpputest) and [DOCtest](https://github.com/onqtam/doctest) tests using the [Test Explorer for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-test-explorer). It also have basic support for [Google Benchmark](https://github.com/google/benchmark). diff --git a/documents/configuration/test.advancedExecutables.md b/documents/configuration/test.advancedExecutables.md index 8f66861c..8128e9eb 100644 --- a/documents/configuration/test.advancedExecutables.md +++ b/documents/configuration/test.advancedExecutables.md @@ -64,6 +64,7 @@ If it is an object it can contains the following properties: | `gtest` | Object with framework specific settings. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#framework-specific-settings) | | `doctest` | Object with framework specific settings. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#framework-specific-settings) | | `gbenchmark` | Object with framework specific settings. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#framework-specific-settings) | +| `cpputest` | Object with framework specific settings. [Detail](https://github.com/matepek/vscode-catch2-test-adapter/blob/master/documents/configuration/test.advancedExecutables.md#framework-specific-settings) | The `pattern` (or the `executables` used as string or an array of strings) can contain [_search-pattern_](https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options). @@ -246,6 +247,10 @@ For example: - `Catch v2.11.1` + `/Catch v(\d+)\.(\d+)\.(\d+)\s?/` -> `[2, 11, 1]` +In case of `cpputest` the helpRegex can be as following. + +- `[-g|sg|xg|xsg groupName]... [-n|sn|xn|xsn testName]...` + ### ignoreTestEnumerationStdErr As the name says test enumeraton will ignore std::err output. diff --git a/src/framework/CppUTestRunnable.ts b/src/framework/CppUTestRunnable.ts index bddca6ce..9708ce52 100644 --- a/src/framework/CppUTestRunnable.ts +++ b/src/framework/CppUTestRunnable.ts @@ -24,7 +24,7 @@ export class CppUTestRunnable extends AbstractRunnable { } private getTestGrouping(): TestGrouping { - // TODO: Reconsider grouping + // TODO: Consider grouping based on passed/failed if (this.properties.testGrouping) { return this.properties.testGrouping; } else { diff --git a/src/framework/CppUTestTest.ts b/src/framework/CppUTestTest.ts index 58997798..1e8c677e 100644 --- a/src/framework/CppUTestTest.ts +++ b/src/framework/CppUTestTest.ts @@ -89,7 +89,9 @@ export class CppUTestTest extends AbstractTest { if (lines.length > 1 && failedTest !== null) { const filePath = failedTest[2].split('/').pop(); const lineNumber = Number(failedTest[3]) - 1; - eventBuilder.appendDecorator(filePath, lineNumber, [lines[3], lines[4]]); + const expected = lines.find(value => /^\texpected/.test(value)); + const actual = lines.find(value => /^\tbut was/.test(value)); + eventBuilder.appendDecorator(filePath, lineNumber, [expected ? expected : '', actual ? actual : '']); } const event = eventBuilder.build(output.replace(/\): error: /g, '): error: \n')); diff --git a/test/framework/CppUTestTest.test.ts b/test/framework/CppUTestTest.test.ts index 32454238..25615158 100644 --- a/test/framework/CppUTestTest.test.ts +++ b/test/framework/CppUTestTest.test.ts @@ -25,8 +25,8 @@ describe(path.basename(__filename), function () { 'TEST(UtestShell, PassedCheckEqualWillIncreaseTheAmountOfChecks)', '/workspaces/cpputest-4.0/tests/CppUTest/UtestTest.cpp:90: error: Failure in TEST(UtestShell, PassedCheckEqualWillIncreaseTheAmountOfChecks)', 'LONGS_EQUAL(10, fixture.getCheckCount()) failed', - 'expected <10 (0xa)>', - 'but was < 1 (0x1)>', + '\texpected <10 (0xa)>', + '\tbut was < 1 (0x1)>', ' - 47 ms', ].join(EOL); @@ -43,7 +43,7 @@ describe(path.basename(__filename), function () { decorations: [ { file: 'UtestTest.cpp', - hover: 'expected <10 (0xa)>\nbut was < 1 (0x1)>', + hover: '\texpected <10 (0xa)>\n\tbut was < 1 (0x1)>', line: 89, message: '⬅ expected <10 (0xa)>; but was < 1 (0x1)>', }, @@ -57,6 +57,45 @@ describe(path.basename(__filename), function () { assert.deepStrictEqual(cpputest.lastRunEvent, expected); }); + it('parses another failed test', function () { + const output = [ + 'TEST(read_rssi, min_rssi_with_min_gain)', + '/workspaces/cpputest-4.0/tests/CppUTest/test_read_rssi.cpp:176: error: Failure in TEST(read_rssi, min_rssi_with_min_gain)', + '\texpected <-1984>', + '\tbut was <-1987>', + 'difference starts at position 4 at: < -1987 >', + ' ^', + '', + '- 47 ms', + ].join(EOL); + + const ev = cpputest.parseAndProcessTestCase('runid', output, 42, null, ''); + + const expected: TestRunEvent = { + testRunId: 'runid', + type: 'test', + test: cpputest.id, + message: output, + state: 'failed', + description: '(47ms)', + tooltip: 'Name: TestCase.TestName\n⏱Duration: 47ms', + decorations: [ + { + file: 'test_read_rssi.cpp', + hover: '\texpected <-1984>\n\tbut was <-1987>', + line: 175, + message: '⬅ expected <-1984>; but was <-1987>', + }, + ], + }; + + assert.strictEqual(cpputest.description, ev.description); + assert.strictEqual(cpputest.tooltip, ev.tooltip); + assert.strictEqual(cpputest.lastRunMilisec, 47); + assert.deepStrictEqual(ev, expected); + assert.deepStrictEqual(cpputest.lastRunEvent, expected); + }); + it('parses passed test', function () { const output = ['TEST(UtestShell, compareDoubles) - 30 ms'].join(EOL);