what is required for a class to be found by console launcher? #4764
Replies: 6 comments 11 replies
-
note, one observation is that if I run:
where I basically take the full classpath of genTest.java which includes some of junits own test examples I get:
So it is able to discover test classes...just not the one I want it to discover ;) |
Beta Was this translation helpful? Give feedback.
-
From https://docs.junit.org/current/user-guide/#running-tests-console-launcher-options-discovering-tests
|
Beta Was this translation helpful? Give feedback.
-
What is the exact output of |
Beta Was this translation helpful? Give feedback.
-
Also - if some can make a jar with a test in it that get found by console launcher that would be useful - does not need to have jbang involved i can figure out the delta from there :) |
Beta Was this translation helpful? Give feedback.
-
also - and this is what I don't understand:
aso its not even able to find it when excplictly requested - which is what i find weird as its on the classpath with a jar that has the classes (as far as I can see) |
Beta Was this translation helpful? Give feedback.
-
You wrote that it works with a main method within the test class, right? I guess, that's due to the main (and therefore the test class) is put on the application class loader of the outer What happens, if you move all the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to figure out why a jar with code like this:
is not found by ConsoleLauncher scan classpath when using it with jbang
While it is picked up if I manually do this:
but i would really just like junit console launcher do it so i dont have to have to carry around the junit test code.
Steps to reproduce:
Install jbang from https://jbang.dev/download or just run
curl -Ls https://sh.jbang.dev | bash -s - app setup
Make a class and a generate junit test suite:
(note: the content of
hello.java
is not relevant; just there to generatehelloTest.java
)Now you have a
hello.java
andhelloTest.java
and you can run the tests using:which will give some output like this:
Showing that the test is runnable - but I really would prefer to not have that
main
method in thehelloTest.java
but rather just run using junit console laucher:
and then just run:
The
jbang info classpath helloTest.java
returns the classpath - you can also just get the jar with no dependenciesjbang info jar helloTest.java
but it seem to make no diff.Also tried adding them in a package (instead of default package)
But consoleLauncher never locates the
helloTest.java
class and I haven't been able to locate why it is not found.Any ideas/suggestions on why they are not found? Whats the magic needed? :)
Beta Was this translation helpful? Give feedback.
All reactions