Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions launchable/commands/record/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,10 @@ def recorded_result() -> Tuple[int, int, int, float]:
rows = [[file_count, test_count, success_count, fail_count, duration]]
click.echo(tabulate(rows, header, tablefmt="github", floatfmt=".2f"))

if duration == 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please write a test for your change?

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 added a test case

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please check what the output looks like test case count is 0? I guess that another warning might be displayed. If so, this warning might be not necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If test case count is zero it just prints the following and returns:
https://github.com/launchableinc/cli/blob/991e9197c1354f016cca60e2a4bced23638bac22/launchable/commands/record/tests.py#L618-L620

(cli) gweerakutti@gayans-macbook-pro cli % launchable record build --name "no_tests"                                              
/Users/gweerakutti/.local/share/virtualenvs/cli-JevRS2r6/lib/python3.9/site-packages/launchable/version.py:1: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  from pkg_resources import DistributionNotFound, get_distribution
Launchable transferred 1 more commit from repository /Users/gweerakutti/Documents/code/github/launchableinc/cli
Launchable recorded build no_tests to workspace defaulttm/my-initial-tests with commits from 1 repository:

| Name   | Path   | HEAD Commit                              |
|--------|--------|------------------------------------------|
| .      | .      | 991e9197c1354f016cca60e2a4bced23638bac22 |

Visit https://app.launchableinc.com/organizations/defaulttm/workspaces/my-initial-tests/data/builds/4267492 to view this build and its test sessions
(cli) gweerakutti@gayans-macbook-pro cli % launchable record tests --allow-test-before-build file tests/data/broken_xml/no_testcase.xml 
/Users/gweerakutti/.local/share/virtualenvs/cli-JevRS2r6/lib/python3.9/site-packages/launchable/version.py:1: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  from pkg_resources import DistributionNotFound, get_distribution
Looks like tests didn't run? If not, make sure the right files/directories were passed into `launchable record tests`

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks

click.echo(click.style("\nTotal test duration is 0."
Copy link
Contributor

@ono-max ono-max Jul 28, 2025

Choose a reason for hiding this comment

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

Why did you decide to output this warning before the URL information, such as Visit https://app.launchableinc.com/organizations/{organization}/workspaces/ ...? I wanna know the reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As it related to total duration shown in the table, I output it just after that. Other than that there's no particular reason. If it's better to output warnings at the end, as a practice, I can update it.

Copy link
Contributor

Choose a reason for hiding this comment

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

No, I just wanted to know the reason.

"\nPlease check whether the test duration times in report files are correct.", "yellow"))

click.echo(
"\nVisit https://app.launchableinc.com/organizations/{organization}/workspaces/"
"{workspace}/test-sessions/{test_session_id} to view uploaded test results "
Expand Down
12 changes: 12 additions & 0 deletions tests/commands/record/test_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,15 @@ def test_parse_launchable_timeformat(self):
self.assertEqual(parse_launchable_time2.timestamp(), 1621880944.285)

self.assertEqual(INVALID_TIMESTAMP, parse_launchable_timeformat(t3))

@responses.activate
@mock.patch.dict(os.environ, {"LAUNCHABLE_TOKEN": CliTestCase.launchable_token})
def test_when_total_test_duration_zero(self):
write_build(self.build_name)

zero_duration_xml1 = str(Path(__file__).parent.joinpath('../../data/googletest/output_a.xml').resolve())
zero_duration_xml2 = str(Path(__file__).parent.joinpath('../../data/googletest/output_b.xml').resolve())
result = self.cli('record', 'tests', '--build', self.build_name, 'googletest', zero_duration_xml1, zero_duration_xml2)

self.assert_success(result)
self.assertIn("Total test duration is 0.", result.output)
Loading