RFR: 8321192 : j.a.PrintJob/ImageTest/ImageTest.java: Fail or skip the test if there's no printer
Phil Race
prr at openjdk.org
Fri Feb 9 20:07:02 UTC 2024
On Fri, 9 Feb 2024 14:59:06 GMT, Renjith Kannath Pariyangad <rkannathpari at openjdk.org> wrote:
> Hi Reviewers,
> I have updated the test with 'PassFailJFrame' with programmatically generating image and print , please review and let me know your suggestions.
> > > I thought SkippedException looks like a "pass" too ?
> > > What is effectively different by using it here ?
> >
> >
> > No, it's not. If a test throws `jtreg.SkippedException`, then it's reported as **skipped**. It is neither a failure nor a success — it indicates the prerequisites aren't met.
>
> **jtreg FAQ: [What if a test does not apply in a given situation?](https://openjdk.org/jtreg/faq.html#what-if-a-test-does-not-apply-in-a-given-situation)**
>
> “While `@modules` and `@requires` will cover many cases, there may be cases where the determination of whether the test is applicable needs to be determined by the test itself. For example, a test may want to check the presence of a shared library containing compiled native code, and to skip the main body of the test if the library is not available. _In such cases, a test may throw an exception named `jtreg.SkippedException`. […] This exception will be treated specially: unlike for any other exception, the test will be deemed to have passed, but the reason will be set to a message saying that the test was skipped instead of executing normally._”
>
> @prrace Does it explain `jtreg.SkippedException`?
>
> However, `@key printer` also covers the condition in this case.
"the test will be deemed to have passed" is not what we want.
We want it to fail. So don't run these tests unless you have a printer. Otherwise we might as well leave the test as it is.
I see no point in using SkippedException in any of the printer tests unless there's some test-specific circumstance I can't think of.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/17790#issuecomment-1936527905
More information about the client-libs-dev
mailing list