Skip to content
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

Refactor hover and definition tests #118

Merged

Conversation

milesziemer
Copy link
Contributor

  • Moves tests for hover and definition into their own test files.
  • Refactors Harness to use a builder instead of overloaded create methods, and updates other tests to use the builder.
  • Moves StubClient into its own file to be used by hover and definition tests.
  • Adds TestUtils class to house common methods used by tests.
  • Adds setProject method to SmithyTextDocumentService for usage by tests.

Eventually I think we can simplify the v1 vs v2 tests more since some of them are shared, and make these kinds of tests parameterized with junit5.

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@milesziemer milesziemer requested a review from a team as a code owner August 28, 2023 15:43
Copy link
Member

Choose a reason for hiding this comment

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

We should create a test-utils package or something one day to make it easier to create and maintain JARs like this for tests.

e.g., https://github.com/smithy-lang/smithy/blob/main/smithy-model/src/test/java/software/amazon/smithy/model/JarUtils.java#L33

import org.eclipse.lsp4j.Range;
import software.amazon.smithy.lsp.ext.SmithyProjectTest;

import static org.junit.Assert.assertTrue;
Copy link
Member

Choose a reason for hiding this comment

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

Not necessary, but FYI you can actually make custom JUnit assertions. See for example https://github.com/smithy-lang/smithy/blob/main/smithy-model/src/test/java/software/amazon/smithy/model/ShapeMatcher.java

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like to move the language server to hamcrest and junit5 like the Smithy repo, maybe this can be a part of that. Seems useful

@milesziemer milesziemer force-pushed the refactor-tds-tests branch 3 times, most recently from dd6418d to 5437eb5 Compare August 28, 2023 17:49
- Moves tests for hover and definition into their own test files.
- Refactors Harness to use a builder instead of overloaded `create` methods,
and updates other tests to use the builder.
- Moves StubClient into its own file to be used by hover and definition tests.
- Adds TestUtils class to house common methods used by tests.
- Adds `setProject` method to SmithyTextDocumentService for usage by tests.

Eventually I think we can simplify the v1 vs v2 tests more since some of them
are shared, and make these kinds of tests parameterized with junit5.
@milesziemer milesziemer merged commit 067fcc9 into smithy-lang:use-smithy-syntax Sep 1, 2023
9 checks passed
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.

None yet

2 participants