SkipException

253 views
Skip to first unread message

Alexandru Popescu ☀

unread,
Apr 11, 2007, 12:33:23 PM4/11/07
to userTestNG
Hi all!

This is the text of the initial idea:

[quote]
Based on some old idea, today I have tried to implement a
SkipException. Basically you can throw this exception from one of the
tests, and it will be considered skipped and not failed. What I have
done next was adding the possibility to provide a date by which the
test should be fixed. If the runtime date is newer than the date in
the exception then the SkipException is transformed in a failure.

Here is an example:

[code]
public class SkippedExceptionTest {
@Test
public void genericSkipException() {
throw new SkipException("some skip message");
}

@Test
public void timedSkipException() {
throw new SkipException("another skip message", "2007/04/09");
}
}
[/code]

Report (if run today):

FAILED: timedSkipException
org.testng.SkipException: another skip message; Test must have been
enabled by: 2007/04/09
... Removed 22 stack frames
SKIPPED: genericSkipException

Report (if run on 2007/04/09):

SKIPPED: timedSkipException
SKIPPED: genericSkipException

Another cool think about SkipException is that in the reports (or at
least in a couple :-) ), the skipped test will be accompanied by the
exception message (the bad side is that not only the message is
included but the trace, but considering it is part of the TestNG most
of it is trimmed).

There is still a small problem (I haven't got time to address it yet):
the expiration comparison is done on day basis for the moment.

Please let me know what do you think about this.
[/quote]

Meanwhile, I have got some feedback and a couple of new ideas, but
please jump in and let me know what do you think.

bests,

./alex
--
.w( the_mindstorm )p.
TestNG co-founder
EclipseTestNG Creator

Alex Ruiz

unread,
Apr 12, 2007, 11:27:48 AM4/12/07
to testng...@googlegroups.com
Hi Alexandru,

I have a silly question...is throwing SkipException similar to JUnit's @Ignore? What about a @Skip annotation? (I'm not sure if TestNG has it already)

Thanks!
Alex.

Cédric Beust ♔

unread,
Apr 12, 2007, 11:48:50 AM4/12/07
to testng...@googlegroups.com
On 4/12/07, Alex Ruiz <alex.r...@gmail.com> wrote:
Hi Alexandru,

I have a silly question...is throwing SkipException similar to JUnit's @Ignore? What about a @Skip annotation? (I'm not sure if TestNG has it already)

We already have one:  @Test(enabled=false).

SkipException is convenient when the decision to ignore the test must be made at runtime.

--
Cédric

Alex Ruiz

unread,
Apr 12, 2007, 12:18:53 PM4/12/07
to testng...@googlegroups.com
Yeah...I see...but what about the reason the test is skipped (e.g. for reporting)?

I might be missing something...I don't get the part "SkipException is convenient when the decision to ignore the test must be made at runtime"....if I needed to skip a test, I would have to throw SkipException, which involves writing code and compiling it...what is the difference between that and adding a @Skip annotation to the code?

Thanks!
Alex.

Steve Loughran

unread,
Apr 12, 2007, 12:42:33 PM4/12/07
to testng...@googlegroups.com
On 12/04/07, Alex Ruiz <alex.r...@gmail.com> wrote:
> Yeah...I see...but what about the reason the test is skipped (e.g. for
> reporting)?
>
> I might be missing something...I don't get the part "SkipException is
> convenient when the decision to ignore the test must be made at
> runtime"....if I needed to skip a test, I would have to throw SkipException,
> which involves writing code and compiling it...what is the difference
> between that and adding a @Skip annotation to the code?
>

because it may depend on the state of the world, such as whether a
remote system was visible. There's no point trying to d/l artifacts
from apache.org if it isnt reachable; detecting a failure to connect
to a server and then skipping is a more obvious a cue that a test
didnt run than just using an if(!offline) { } to omit some work when
offline, which is what I do today

-steve

Cédric Beust ♔

unread,
Apr 12, 2007, 12:51:27 PM4/12/07
to testng...@googlegroups.com
On 4/12/07, Alex Ruiz <alex.r...@gmail.com> wrote:
Yeah...I see...but what about the reason the test is skipped (e.g. for reporting)?

I might be missing something...I don't get the part "SkipException is convenient when the decision to ignore the test must be made at runtime"....if I needed to skip a test, I would have to throw SkipException, which involves writing code and compiling it...what is the difference between that and adding a @Skip annotation to the code?

You just answered your own question:  an annotation is static, code that you write is executed at runtime.

--
Cédric

Ilya Sterin

unread,
Apr 12, 2007, 7:36:19 PM4/12/07
to testng...@googlegroups.com
yeah, but you can use annotation transformers to nicely resolve this
as I did the other day.

Ilya

On 4/12/07, Cédric Beust ♔ <cbe...@google.com> wrote:
>
>

Reply all
Reply to author
Forward
0 new messages