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

Add integration tests #39

Merged
merged 5 commits into from
Apr 18, 2023
Merged

Add integration tests #39

merged 5 commits into from
Apr 18, 2023

Conversation

ldennington
Copy link
Collaborator

@ldennington ldennington commented Mar 30, 2023

This series adds integration tests, using the example set with the end-to-end tests in #33.

The first commit refactors certain components of the end-to-end tests to prepare for the new integration suite. The second commit adds the basic infrastructure and tests for the core bundle server commands. The third adds tests for basic daemon functionality. The fourth updates the Makefile to add targets to run unit tests, integration tests, and all tests. The fifth adds applicable tests from the integration suite to CI.

@ldennington
Copy link
Collaborator Author

ldennington commented Mar 30, 2023

@vdye @derrickstolee - Opening this as a draft PR, as I'd like to add some more commands and an actions workflow before merging. However, I'm sure there are lots of areas for improvement, so wanted to open up the floor for feedback as soon as possible.

@ldennington ldennington self-assigned this Mar 30, 2023
Copy link
Collaborator

@derrickstolee derrickstolee left a comment

Choose a reason for hiding this comment

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

Good start to the new test category. I'm confused about the boundaries between the test classes.

Another thought: is there value in having a single Cucumber project, but splitting e2e or integration into different categories? Then the Makefile could run the different categories for different build targets. Our workflows could be organized to run unit and integration tests in one build, and e2e tests in another build (if we need to parallelize them).

Copy link
Collaborator

@vdye vdye left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! In addition to what I've already noted in individual comments, one general recommendation I have would be to keep the architecture a bit simpler as you add more tests/steps. The deeper the call stack is for a given operation, the harder it is to understand and subsequently modify or extend its behavior.

In the context of these tests, one way to avoid having lots of wrapper layers (functions or classes) would be to pull more logic into the BundleServerWorld or even the step_definitions. That needs to be balanced with avoiding code duplication, although even then it's okay to have a little repeated code if it makes for better readability.

@ldennington ldennington force-pushed the integration-tests branch 2 times, most recently from 9128704 to 24632ca Compare April 13, 2023 22:36
@ldennington ldennington marked this pull request as ready for review April 13, 2023 22:38
@ldennington
Copy link
Collaborator Author

I believe all the previous feedback has been addressed, either directly or via another suggested refactor. Please share any additional suggestions you have for improvement on the new changes (command tests, the refactors for sharing code, CI, etc.)

Copy link
Collaborator

@vdye vdye left a comment

Choose a reason for hiding this comment

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

Awesome tests! The .features are descriptive and thoroughly verify on-disk behavior, and the shared infrastructure between e2e and integration is quite elegant.

I had a few super minor nits + some suggestions for possible consolidation (although I'm fine deferring that to a separate issue/future change). Otherwise, 🚢.

Comment on lines -7 to +9
private root: string
private remote: RemoteRepo | undefined

root: string
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why was root made public?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's used in the remote.ts step definition to run Git commands, for example in Given('{int} commits are pushed to the remote branch {string}'). Sorry about the lack of link - I don't think permalinks are suppported in PRs, or if they are I have not figured out how to obtain them 😬.

Returning to the topic at hand, I could change it to be private again and add a getter if that would be better though!

@vdye
Copy link
Collaborator

vdye commented Apr 17, 2023

@ldennington I've also unmarked e2e-test as required for merging, and will make Integration and end-to-end tests (or whichever name it ends up with) required after merging this.

Update necessary components of existing e2e tests to prepare for new
integration test suite. This includes:

1. Moving package-related files (package-lock.json, package.json, and
tsconfig.json) out of the 'e2e' directory and into 'test' and updating
package.json to not be e2e-test specific. This will allow both suites to
be combined into a single Typescript package in upcoming patches.i

2. Moving certain classes currently in the e2e 'step_definitions',
'support', and 'classes' directories that will be needed by integration
tests into a new 'shared' directory. This led to notable refactorings to
implement the shared 'BundleServerWorld' class as a parent and a new
'E2EBundleServerWorld' class as a child. A similar
'IntegrationBundleServerWorld' class will be added in a future patch.

3. Updating the 'require' statement in the e2e tests' config to identify
the correct 'features' directories with the new architecture. This
indicates to Cucumber that it should look in multiple directories for
features. The VSCode settings have been updated to recognize these
directories as well.

Signed-off-by: Lessley Dennington <[email protected]>
Add integration tests for the following commands, which represent core
bundle server functionality:

1. init
2. delete
3. update
4. start
5. stop

Signed-off-by: Lessley Dennington <[email protected]>
Add basic integration tests for daemon start/stop functionality.

Signed-off-by: Lessley Dennington <[email protected]>
Add three new Makefile targets:

1. 'test' - runs the project's unit tests
2. 'test-integration' -  installs the required dependencies for and runs
the project's integration tests, following the example set in [1]
3. 'test-all' - runs all project test suites (unit, integration, and
end-to-end)

1: a6ff664

Signed-off-by: Lessley Dennington <[email protected]>
Update existing test.yml workflow to run integration tests.
@vdye vdye merged commit 88fe9de into main Apr 18, 2023
@vdye vdye deleted the integration-tests branch April 18, 2023 23:15
@vdye
Copy link
Collaborator

vdye commented Apr 18, 2023

Branch protection rules have been updated!

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.

3 participants