launchableinc / cli

Launchable CLI
https://pypi.org/project/launchable/
Apache License 2.0
24 stars 13 forks source link

Ignore $InnerClass in JUnit 5 and Gradle #862

Closed ninjinkun closed 5 months ago

ninjinkun commented 5 months ago

JUnit 5 has @Nested annotation. With the annotation, users can write nested tests. But the nested tests are outputted as ClassName$InnerClass style. And Launchable CLI cannot detect the nested test cases on subsetting. So I updated the following changes:

ninjinkun commented 5 months ago

@Konboi I have a question. If launchable record tests sends the same test class several times, does Launchable aggregate those durations?

For example, the current CLI record tests with inner classes like:

org.ninjinkun.Test1$Inner1 0.3sec
org.ninjinkun.Test1$Inner2 0.2sec
org.ninjinkun.Test1$Inner3 0.1sec

This PR removes inner classes and make the CLI send same test names several times like this:

org.ninjinkun.Test1 0.3sec
org.ninjinkun.Test1 0.2sec
org.ninjinkun.Test1 0.1sec

I expect Lauchable aggregate the total duraitons like org.ninjinkun.Test1 0.6sec. Does Launchable work like this?

Konboi commented 5 months ago

I expect Lauchable aggregate the total duraitons like org.ninjinkun.Test1 0.6sec. Does Launchable work like this?

Yes or No.

In test cases level.

Launcahble records each test case

1. org.ninjinkun.Test1, 0.3sec
2. org.ninjinkun.Test1, 0.2sec
3. org.ninjinkun.Test1, 0.1sec

In teset series level. The data will be below and this data will be shown on the WebApp.

1, org.ninjinkun.Test1 0.6sec

By the way, if the test result is like below,

org.ninjinkun.Test1 0.3sec PASS (org.ninjinkun.Test1$Inner1)
org.ninjinkun.Test1 0.2sec FAIL (org.ninjinkun.Test1$Inner12)
org.ninjinkun.Test1 0.1sec PASS  (org.ninjinkun.Test1$Inner3)

test series status will be 'FLAKE` and it will be shown as 'Retried Tests'. Is it OK?

1. org.ninjinkun.Test1, 0.6sec FLAKE 
ninjinkun commented 5 months ago

By the way, if the test result is like below,

org.ninjinkun.Test1 0.3sec PASS (org.ninjinkun.Test1$Inner1)
org.ninjinkun.Test1 0.2sec FAIL (org.ninjinkun.Test1$Inner12)
org.ninjinkun.Test1 0.1sec PASS  (org.ninjinkun.Test1$Inner3)

test series status will be 'FLAKE` and it will be shown as 'Retried Tests'. Is it OK?

1. org.ninjinkun.Test1, 0.6sec FLAKE 

That's a nice catch! It will not be FLAKE. So, I think we have to aggregate the test cases in inner classes to classes on the CLI.

ninjinkun commented 5 months ago

@Konboi Oh, I found that I misunderstood my context. The test cases in the inner classes have test case names!

[
  {"class": "org.ninjinkun.Test1$Inner1", "tescase": "test1", "status": "PASS", "duration": 0.3 },
  {"class": "org.ninjinkun.Test1$Inner2", "testcase": "test2", "status": "FAIL", "duration": 0.2},
  {"class": "org.ninjinkun.Test1$Inner3", "testcase": "test3", "status": "PASS", "duration":  0.1}
]

The input will be the following result with this PR.

[
  {"class": "org.ninjinkun.Test1", "tescase": "test1", "status": "PASS", "duration": 0.3 },
  {"class": "org.ninjinkun.Test1", "testcase": "test2", "status": "FAIL", "duration": 0.2},
  {"class": "org.ninjinkun.Test1", "testcase": "test3", "status": "PASS", "duration":  0.1}
]

It will not be FLAKE even on the class level, right?

sonarcloud[bot] commented 5 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Konboi commented 5 months ago

The input will be the following result with this PR.

[ {"class": "org.ninjinkun.Test1", "tescase": "test1", "status": "PASS", "duration": 0.3 }, {"class": "org.ninjinkun.Test1", "testcase": "test2", "status": "FAIL", "duration": 0.2}, {"class": "org.ninjinkun.Test1", "testcase": "test3", "status": "PASS", "duration": 0.1} ]

Sounds good.

It will not be FLAKE even on the class level, right?

Yes