Skip to content

Feature/unit tests#63

Merged
nickschwab merged 15 commits intodevelopfrom
feature/unit-tests
Jan 7, 2020
Merged

Feature/unit tests#63
nickschwab merged 15 commits intodevelopfrom
feature/unit-tests

Conversation

@russjohnson09
Copy link
Copy Markdown
Contributor

@russjohnson09 russjohnson09 commented Dec 18, 2019

Fixes #60

This PR is ready for review.

Risk

This PR makes no API changes.

Testing Plan

npm run test script added which will run tests under the tests/node directory. Right now there are basic examples of request, response, and notification rpcs.

Summary

Basic request, response, and notification rpc tests copied over from the java suite sdk and adjusted to work with mocha instead of JUnit.

CLA

Copy link
Copy Markdown
Contributor

@crokita crokita left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some feedback

Comment thread tests/node/rpc/messages/OnHmiStatusTests.js
const assertNullOrUndefined = Validator.assertNullOrUndefined.bind(Validator);
const assertNotNull = Validator.assertNotNull.bind(Validator);

const testNullBase = Validator.testNullBase.bind(Validator,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be better to just invoke Validator.testNullBase directly where it is used in the case where it only appears once in the file. bind could change to apply if the context is still necessary

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

it ('testRpcValues', function (done) {
let msg = this.msg;
// Test Values
const testSupportedDiagModes = msg.getSupportedDiagModes();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be easier to check if all these properties were accounted for if they were written in the same order as the set methods in the createMessage function, or if they were more lexically close together.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the order here to match the param order in the mobile rpc spec https://github.com/smartdevicelink/rpc_spec/blob/version/6_0_0/MOBILE_API.xml . setSystemSoftwareVersion and setHMICapabilities were missing and so those were added to this now as well.

const assertNull = Validator.assertNull.bind(Validator);
const assertNullOrUndefined = Validator.assertNullOrUndefined.bind(Validator);
const assertNotNull = Validator.assertNotNull.bind(Validator);
const testNullBase = Validator.testNullBase.bind(Validator,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of these seem to be unused in here and in other files. The linter should be able to find unused references.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed unused variables

assertNotNull(Test.NOT_NULL, rpcMessage);
testNullBase(rpcMessage);

assertNullOrUndefined(Test.NULL, rpcMessage.getSdlMsgVersion());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have/use a string that describes that null or undefined are the expected values (ex. Test.NULL_OR_UNDEFINED)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the the message for these assertion where it was a generic message. The error returned by default is accurate. For this one if there is an error it should say something like "line 116 expected null to not be null or undefined". The default messages were something I copied over from the java suite but they are not really relevant here. The custom error messages like 'Correlation ID should be defined.' are still there.

Comment thread tests/node/rpc/structs/ImageTests.js Outdated
const assertNullOrUndefined = Validator.assertNullOrUndefined.bind(Validator);
const assertNotNull = Validator.assertNotNull.bind(Validator);

let msg;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks inconsistent with the other files with how they declare msg from within the tests

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added BaseStructTests which acts similarly to BaseRpcTests.

Comment thread tests/Validator.js Outdated

/**
* Validate an rpcMessage matches the given expectedParameters
* @param {RpcMessage} rpcMessage - ssageto validate against.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the docs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed typo

Copy link
Copy Markdown

@nickschwab nickschwab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revisions requested - see inline comments.

Comment thread tests/node/rpc/enums/AppHMITypeTests.js Outdated
Comment thread tests/Validator.js Outdated
Comment thread tests/Validator.js Outdated
Comment thread tests/node/rpc/messages/BaseRpcTests.js Outdated
Comment thread tests/Validator.js Outdated
Comment thread tests/node/util/VersionTest.js Outdated
Comment thread tests/node/util/BsonTest.js Outdated
Comment thread tests/node/util/BitConverterTest.js Outdated
@nickschwab nickschwab merged commit c6d6440 into develop Jan 7, 2020
@crokita crokita deleted the feature/unit-tests branch March 3, 2020 21:00
@crokita crokita restored the feature/unit-tests branch March 3, 2020 21:01
@crokita crokita deleted the feature/unit-tests branch March 3, 2020 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Unit Tests For Basic Request, Response, and Notification RPCs

3 participants