File tree Expand file tree Collapse file tree 3 files changed +22
-5
lines changed
main/java/org/eolang/jucs
test/java/org/eolang/jucs Expand file tree Collapse file tree 3 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 1212[ ![ License] ( https://img.shields.io/badge/license-MIT-green.svg )] ( https://github.com/objectionary/jucs/blob/master/LICENSE.txt )
1313
1414There is a simple annotation in this package, which may help you
15- turn files in classpath into sources of a JUnit test method.
15+ turn files in classpath into sources of a JUnit5 test method.
1616
1717First, add this to your ` pom.xml ` :
1818
@@ -31,7 +31,7 @@ import org.junit.jupiter.params.ParameterizedTest;
3131
3232final class SimpleTest {
3333 @ParameterizedTest
34- @ClasspathSource (value = " org/example" , glob = " **/*.yaml" )
34+ @ClasspathSource (value = " org/example/ " , glob = " **/*.yaml" )
3535 void simpleTest (String y ) {
3636 // In the "y" variable is the content of the YAML file
3737 }
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ public Stream<? extends Arguments> provideArguments(
8181 */
8282 private Collection <String > yamls (final String prefix ) {
8383 final Collection <String > out = new LinkedList <>();
84- final String home = String .format ("%s%s" , this .annotation . value (), prefix );
84+ final String home = String .format ("%s/ %s" , this .sanitized (), prefix );
8585 final String folder = new UncheckedText (
8686 new TextOf (new ResourceOf (home ))
8787 ).asString ();
@@ -99,4 +99,21 @@ private Collection<String> yamls(final String prefix) {
9999 }
100100 return out ;
101101 }
102+
103+ /**
104+ * Get sanitized home path.
105+ * @return The path without front slash and with a tailing one
106+ */
107+ private String sanitized () {
108+ final String path = this .annotation .value ();
109+ int begin = 0 ;
110+ if (path .charAt (0 ) == '/' ) {
111+ begin = 1 ;
112+ }
113+ int end = path .length ();
114+ if (path .charAt (end - 1 ) == '/' ) {
115+ end -= 1 ;
116+ }
117+ return path .substring (begin , end );
118+ }
102119}
Original file line number Diff line number Diff line change 3434final class JucsProviderTest {
3535
3636 @ ParameterizedTest
37- @ ClasspathSource ("com/yegor256/jucs/ " )
37+ @ ClasspathSource ("com/yegor256/jucs" )
3838 void simpleTest (final String file ) {
3939 Assertions .assertEquals (file , "Hello, world!\n " );
4040 }
4141
4242 @ ParameterizedTest
43- @ ClasspathSource (value = "com/yegor256/jucs/ " , glob = "**/*.text" )
43+ @ ClasspathSource (value = "/ com/yegor256/jucs" , glob = "**/*.text" )
4444 void findsInFolders (final String file ) {
4545 Assertions .assertEquals (file , "hey!\n " );
4646 }
You can’t perform that action at this time.
0 commit comments