I’ve got a test structured something like: ```cont...
# kotest
b
I’ve got a test structured something like:
Copy code
context("when starting a Foo") {
    context("and thing A happens") {
        should("throw an error") {
        }
    }
    context("and thing B happens") {
        should("throw an error") {
        }
    }
}
and when I get a failure, in the junit output I just get:
"should throw an error"
for context, which is ambiguous between those 2 cases. Is there a way to get the full context “tree” when a failure happens?
s
not in junit as it doesn't understand these nested tests
by junit you mean the xml ?
b
damn
yeah
s
kotest has it's own xml that is compatible that allows you to tell it to use the full name
b
ah ok…i’ll look into that. thanks!
@sam just getting a chance to take a look at this…what dependency do I need to get
JunitXmlReporter
? (from the link you sent here: https://kotest.io/docs/extensions/junit_xml.html)
Also, any tips on where to find how to do that reporter config block in maven?
s
kotest-extensions-junit or -junit-xml
one of the two
b
great, thanks
(
kotest-extensions-junit5
?)
s
yeah that's sounds like it
b
ah damn, only since 4.3.0 looks like. is that what requires a more recent kotlin version?
s
it's been around for ages
what version are you running
b
i’m on 4.1.3 and still on kotlin 1.3
s
4.3 doesn't need 1.4
b
cool…i’ll try upgrading
is it possible to do that build output dir piece in maven?
s
yeah I'd imagine so but not sure how as I don't use maven
You could just hardcode it if you know your build path
it's just a system property
Or maven might expose some variables ${project.buildDir} or something
b
yeah the prop should be doable i think…dunno what
useJUnitPlatform()
is doing
s
useJUnitPlatform is just telling gradle to enable junit5platform support
you don't need that in maven
b
ok cool
hm, i don’t see
JunitXmlReporter
in either of those…trying to look at github but don’t see either of those repos under `kotest`…are they under a different name?
simplest thing to do if you don't want to upgrade is just copy that class into your test sources and use it from there
b
ah, didn’t realize they were all under kotest-extensions. thanks
b
it looks like
kotest-extensions-junitxml
has been around for a while, it has a 4.1.3 version. and
JunitXmlReporter
seems like it’s been around since that timeframe
s
yeah I know it's been around for ages
b
but for some reason it still doesn’t show up.
s
I wrote it years ago
gonna be quicker to copy n paste that file
b
sure, but i’d rather keep it more “official”
s
upgrade to 4.3 is the way to keep it official 🙂
b
that doesn’t appear to fix it
i think it’s because it’s requiring i do
<type>pom</type>
when adding the junitxml dep
s
because its maven
io.kotestkotest extensions junitxml jvm4.3.0
b
ah yeah, that should do it
ok, that and moving to 4.3.2 finds
JunitXmlReporter
(it’s not in 4.1.3 looks like)
thanks sam 👍
👍🏻 1
@sam sorry to keep harping on this…should I expect that the JunitXmlReporter overwrites the existing files? I do see the proper names in the file JunitXmlReporter spits out, but it was in a different directory. When I change the output directoy in JunitXmlReporter to where the other files are written to it looks like I end up with the original ones, not the ones with the full names from
JunitXmlReporter
s
It's something that would run alongside the existing one
b
Ok, so I should have those output to a different location and then have whatever’s reading them look at that location?
👍🏻 1
s
kotest has no control over what reports gradle is generating
exactly
b
Ok…one other question: i should not expect that this changes the console output of junit/surefire or whatever…those will still have the shorter test case names?
s
yes
b
ok
s
this is just an XML file generator
b
thanks
s
do you want longer names in surefire ?
b
ideally, yeah
s
add a ticket - I was thinking of adding some configuration options for this to 4.5
so if you write it up, I'll implement it
b
ok cool, will do
s
nice
by longer test names I assume you mean the full test path for nested tests
b
right
i’ll clarify that
Ah, already ahead of me 🙂