| Newsgroups |
gmane.comp.java.junit.user |
| Message-ID |
<[email protected]> |
Hi,
my problem is how to nicely present to the user that things have failed outside of a test method (our runner is a bit different and can't use the regular runner's ways of doing it).
I guess I can do with failure.getDescription().getMethodName() == null, although it would have been nicer to be able to know if it failed in BeforeClass/AfterClass etc.
BR,
Chris
--------------------------------------------
On Mon, 12/15/14, David Saff [email protected] [junit] <[email protected]> wrote:
Subject: Re: [junit] How to reliable identify Failure caused by @BeforeClass?
To: [email protected]
Date: Monday, December 15, 2014, 6:45 PM
At the moment, I don't think
there's machine-readable metadata that would help
identify the source of a failure. That line in the javadoc
is supposed to simply warn that some Failures thrown
won't have Descriptions attached that refer to tests
already in the test tree, if the Failure reported is in test
machinery that doesn't correspond to an individual
test.
What is it you're
hoping to do?
On Mon, Dec 15, 2014 at
7:11 AM, Chris [email protected]
[junit] <[email protected]>
wrote:
Hi,
I ran into some issue with a custom runner that I'm
maintining and I can do an ugly workaround to fix it, but
I'd like to solve it the "right way".
My issue is how to I know if a
org.junit.runner.notification.Failure is caused by a normal
testcase or if it caused by a crash in a
@BeforeClass-annotated method.
The javadoc for Failure says this:
* A <code>Failure</code> holds a description of
the failed test and the
* exception that was thrown while running it. In most cases
the {@link org.junit.runner.Description}
* will be of a single test. However, if problems are
encountered while constructing the
* test (for example, if a {@link org.junit.BeforeClass}
method is not static), it may describe
* something other than a single test.
But I can't figure out *how* I can read this failure and
know that it is BeforeClass or not. I did some really ugly
hacks by looking at the backtrace to see where it was
triggered from that that's really fragile and I'd
like something better.
I tried reading through Description and see if I could
figure it out, but no luck thus far.
TIA,
Chris
#yiv4766428982 #yiv4766428982 --
#yiv4766428982ygrp-mkp {
border:1px solid #d8d8d8;font-family:Arial;margin:10px
0;padding:0 10px;}
#yiv4766428982 #yiv4766428982ygrp-mkp hr {
border:1px solid #d8d8d8;}
#yiv4766428982 #yiv4766428982ygrp-mkp #yiv4766428982hd {
color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px
0;}
#yiv4766428982 #yiv4766428982ygrp-mkp #yiv4766428982ads {
margin-bottom:10px;}
#yiv4766428982 #yiv4766428982ygrp-mkp .yiv4766428982ad {
padding:0 0;}
#yiv4766428982 #yiv4766428982ygrp-mkp .yiv4766428982ad p {
margin:0;}
#yiv4766428982 #yiv4766428982ygrp-mkp .yiv4766428982ad a {
color:#0000ff;text-decoration:none;}
#yiv4766428982 #yiv4766428982ygrp-sponsor
#yiv4766428982ygrp-lc {
font-family:Arial;}
#yiv4766428982 #yiv4766428982ygrp-sponsor
#yiv4766428982ygrp-lc #yiv4766428982hd {
margin:10px
0px;font-weight:700;font-size:78%;line-height:122%;}
#yiv4766428982 #yiv4766428982ygrp-sponsor
#yiv4766428982ygrp-lc .yiv4766428982ad {
margin-bottom:10px;padding:0 0;}
#yiv4766428982 #yiv4766428982actions {
font-family:Verdana;font-size:11px;padding:10px 0;}
#yiv4766428982 #yiv4766428982activity {
background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}
#yiv4766428982 #yiv4766428982activity span {
font-weight:700;}
#yiv4766428982 #yiv4766428982activity span:first-child {
text-transform:uppercase;}
#yiv4766428982 #yiv4766428982activity span a {
color:#5085b6;text-decoration:none;}
#yiv4766428982 #yiv4766428982activity span span {
color:#ff7900;}
#yiv4766428982 #yiv4766428982activity span
.yiv4766428982underline {
text-decoration:underline;}
#yiv4766428982 .yiv4766428982attach {
clear:both;display:table;font-family:Arial;font-size:12px;padding:10px
0;width:400px;}
#yiv4766428982 .yiv4766428982attach div a {
text-decoration:none;}
#yiv4766428982 .yiv4766428982attach img {
border:none;padding-right:5px;}
#yiv4766428982 .yiv4766428982attach label {
display:block;margin-bottom:5px;}
#yiv4766428982 .yiv4766428982attach label a {
text-decoration:none;}
#yiv4766428982 blockquote {
margin:0 0 0 4px;}
#yiv4766428982 .yiv4766428982bold {
font-family:Arial;font-size:13px;font-weight:700;}
#yiv4766428982 .yiv4766428982bold a {
text-decoration:none;}
#yiv4766428982 dd.yiv4766428982last p a {
font-family:Verdana;font-weight:700;}
#yiv4766428982 dd.yiv4766428982last p span {
margin-right:10px;font-family:Verdana;font-weight:700;}
#yiv4766428982 dd.yiv4766428982last p
span.yiv4766428982yshortcuts {
margin-right:0;}
#yiv4766428982 div.yiv4766428982attach-table div div a {
text-decoration:none;}
#yiv4766428982 div.yiv4766428982attach-table {
width:400px;}
#yiv4766428982 div.yiv4766428982file-title a, #yiv4766428982
div.yiv4766428982file-title a:active, #yiv4766428982
div.yiv4766428982file-title a:hover, #yiv4766428982
div.yiv4766428982file-title a:visited {
text-decoration:none;}
#yiv4766428982 div.yiv4766428982photo-title a,
#yiv4766428982 div.yiv4766428982photo-title a:active,
#yiv4766428982 div.yiv4766428982photo-title a:hover,
#yiv4766428982 div.yiv4766428982photo-title a:visited {
text-decoration:none;}
#yiv4766428982 div#yiv4766428982ygrp-mlmsg
#yiv4766428982ygrp-msg p a span.yiv4766428982yshortcuts {
font-family:Verdana;font-size:10px;font-weight:normal;}
#yiv4766428982 .yiv4766428982green {
color:#628c2a;}
#yiv4766428982 .yiv4766428982MsoNormal {
margin:0 0 0 0;}
#yiv4766428982 o {
font-size:0;}
#yiv4766428982 #yiv4766428982photos div {
float:left;width:72px;}
#yiv4766428982 #yiv4766428982photos div div {
border:1px solid
#666666;height:62px;overflow:hidden;width:62px;}
#yiv4766428982 #yiv4766428982photos div label {
color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}
#yiv4766428982 #yiv4766428982reco-category {
font-size:77%;}
#yiv4766428982 #yiv4766428982reco-desc {
font-size:77%;}
#yiv4766428982 .yiv4766428982replbq {
margin:4px;}
#yiv4766428982 #yiv4766428982ygrp-actbar div a:first-child {
margin-right:2px;padding-right:5px;}
#yiv4766428982 #yiv4766428982ygrp-mlmsg {
font-size:13px;font-family:Arial, helvetica, clean,
sans-serif;}
#yiv4766428982 #yiv4766428982ygrp-mlmsg table {
font-size:inherit;font:100%;}
#yiv4766428982 #yiv4766428982ygrp-mlmsg select,
#yiv4766428982 input, #yiv4766428982 textarea {
font:99% Arial, Helvetica, clean, sans-serif;}
#yiv4766428982 #yiv4766428982ygrp-mlmsg pre, #yiv4766428982
code {
font:115% monospace;}
#yiv4766428982 #yiv4766428982ygrp-mlmsg * {
line-height:1.22em;}
#yiv4766428982 #yiv4766428982ygrp-mlmsg #yiv4766428982logo {
padding-bottom:10px;}
#yiv4766428982 #yiv4766428982ygrp-msg p a {
font-family:Verdana;}
#yiv4766428982 #yiv4766428982ygrp-msg
p#yiv4766428982attach-count span {
color:#1E66AE;font-weight:700;}
#yiv4766428982 #yiv4766428982ygrp-reco
#yiv4766428982reco-head {
color:#ff7900;font-weight:700;}
#yiv4766428982 #yiv4766428982ygrp-reco {
margin-bottom:20px;padding:0px;}
#yiv4766428982 #yiv4766428982ygrp-sponsor #yiv4766428982ov
li a {
font-size:130%;text-decoration:none;}
#yiv4766428982 #yiv4766428982ygrp-sponsor #yiv4766428982ov
li {
font-size:77%;list-style-type:square;padding:6px 0;}
#yiv4766428982 #yiv4766428982ygrp-sponsor #yiv4766428982ov
ul {
margin:0;padding:0 0 0 8px;}
#yiv4766428982 #yiv4766428982ygrp-text {
font-family:Georgia;}
#yiv4766428982 #yiv4766428982ygrp-text p {
margin:0 0 1em 0;}
#yiv4766428982 #yiv4766428982ygrp-text tt {
font-size:120%;}
#yiv4766428982 #yiv4766428982ygrp-vital ul li:last-child {
border-right:none !important;
}
#yiv4766428982
------------------------------------
Posted by: Chris <[email protected]>
------------------------------------