Skip to content

Added Group json option #300

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

Open
wants to merge 7 commits into
base: trunk
Choose a base branch
from
Open

Added Group json option #300

wants to merge 7 commits into from

Conversation

MrJnrman
Copy link
Contributor

@MrJnrman MrJnrman commented May 15, 2025

This PR adds the --json option to the group:fetch command to render the output as raw json.

Changes

  • Add --json flag
  • Display the test group when clearing it
  • If a completed test group exists when trying to enqueue a new test, it will be displayed then cleared in order to complete the action.

Testing Instructions

  1. Checkout this branch
  2. Enqueue 2 or more tests in a group
  3. Run the group
  4. Run qit group:fetch -i <group-identifier> and confirm you get nicely formatted output.
  5. Run qit group:fetch -i <group-identifier> --json and confirm you get raw json.
  6. Clear the group and confirm that you get an ouput.
  7. Enqueue and run a new group and wait until its completed.
  8. Try to enqueue a group again and confirm that it displays the old group and completes the action

@MrJnrman MrJnrman requested a review from a team May 15, 2025 19:02
@MrJnrman MrJnrman self-assigned this May 15, 2025
Copy link
Member

@Luc45 Luc45 left a comment

Choose a reason for hiding this comment

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

Thanks!


public function output_group( OutputInterface $output ): void {
$group = $this->get();
if ( ! array_key_exists( 'group_identifier', $group ) ) {
Copy link

@alopezari alopezari May 16, 2025

Choose a reason for hiding this comment

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

Should we ensure that $group is an array here and in other similar checks in order to make it more robust? Something like:

if ( is_array( $group ) && ! array_key_exists( 'group_identifier', $group ) )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't need to. The function get method on the TestGroup class returns an empty array if the group doesn't exist and everywhere else where we fetch the group directly from the cache has defensive checks in place

@alopezari
Copy link

Thanks for creating this PR @MrJnrman!

Please don't consider my questions/comments as blockers and go ahead if you're happy with Lucas' approval!

Just wanted to test this PR as an opportunity to learn more about groups. Testing instruction step 2 says:

Enqueue 2 or more tests in a group

How can you do that?

@MrJnrman
Copy link
Contributor Author

@alopezari I'm happy to share. To add a test to a group all you have to do is append --group to a command used to run a test. What that will do is differ execution and add the test to a locally declared group. Once you've populated your group, you can execute all of them at once by running qit group:run. If there are any e2e/activation tests in your group, they'll be executed automatically and the QIT manager will be updated once they're complete.

You can also check the docs for more info: https://qit.woo.com/docs/managed-tests/group-tests

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