1

I tried to run with junit5 with stand alone runner the following command: java -jar ex1/lib/junit-platform-console-standalone-1.6.0-M1.jar --select-directory="./ex1/test"

with the following hierarchy:

.
├── ex1
│   ├── lib
│   │   ├── apiguardian-api-1.1.0.jar
│   │   ├── junit-jupiter-api-5.6.0-M1.jar
│   │   ├── junit-platform-commons-1.6.0-M1.jar
│   │   ├── junit-platform-console-standalone-1.6.0-M1.jar
│   │   └── opentest4j-1.2.0.jar
│   ├── mavnat.iml
│   ├── out
│   │   ├── production
│   │   │   └── mavnat
│   │   │       ├── AVLTree$AVLNode.class
│   │   │       ├── AVLTree.class
│   │   │       ├── AVLTree$DeletionBalancer.class
│   │   │       ├── AVLTree$IAVLNode.class
│   │   │       ├── AVLTree$InsertionBalancer.class
│   │   │       ├── AVLTree$Rotations.class
│   │   │       └── TreePrinter.class
│   │   └── test
│   │       └── mavnat
│   │           ├── ActualAVLTree.class
│   │           ├── ActualAVLTree$IAVLNode.class
│   │           ├── AVLSanitizer.class
│   │           ├── AVLTreeTest.class
│   │           ├── AVLTreeTestExternal.class
│   │           ├── DeletionTest.class
│   │           ├── ExTester$10.class
│   │           ├── ExTester$11.class
│   │           ├── ExTester$12.class
│   │           ├── ExTester$13.class
│   │           ├── ExTester$14.class
│   │           ├── ExTester$1.class
│   │           ├── ExTester$2.class
│   │           ├── ExTester$3.class
│   │           ├── ExTester$4.class
│   │           ├── ExTester$5.class
│   │           ├── ExTester$6.class
│   │           ├── ExTester$7.class
│   │           ├── ExTester$8.class
│   │           ├── ExTester$9.class
│   │           ├── ExTester.class
│   │           ├── InsertionTest.class
│   │           ├── META-INF
│   │           │   └── mavnat.kotlin_module
│   │           ├── RotationsTest.class
│   │           ├── SplitTest.class
│   │           ├── SuccessStatus.class
│   │           ├── TesterUtils.class
│   │           ├── Tests.class
│   │           └── TestUtils.class
│   ├── pro-1.docx
│   ├── src
│   │   ├── AVLTree.java
│   │   └── TreePrinter.java
│   └── test
│       ├── AVLSanitizer.java
│       ├── AVLTreeTestExternal.java
│       ├── AVLTreeTest.java
│       ├── DeletionTest.java
│       ├── InsertionTest.java
│       ├── JoinTest.java
│       ├── RotationsTest.java
│       ├── SplitTest.java
│       └── TestUtils.java
└── ex2 

Unfortunately, it seems that Junit launcher doesn't discover the tests.

╷
├─ JUnit Jupiter ✔
└─ JUnit Vintage ✔

Test run finished after 29 ms
[         2 containers found      ]
[         0 containers skipped    ]
[         2 containers started    ]
[         0 containers aborted    ]
[         2 containers successful ]
[         0 containers failed     ]
[         0 tests found           ]
[         0 tests skipped         ]
[         0 tests started         ]
[         0 tests aborted         ]
[         0 tests successful      ]
[         0 tests failed          ]

Does anyone know why tests aren't found? I would expect all the tests to be run and get info about failed tests.

edit: verbose run:

Thanks for using JUnit! Support its development at https://junit.org/sponsoring

Test plan execution started. Number of static tests: 0
╷
├─ JUnit Jupiter
└─ JUnit Jupiter finished after 7 ms.
├─ JUnit Vintage
└─ JUnit Vintage finished after 2 ms.
Test plan execution finished. Number of all tests: 0

Test run finished after 42 ms
[         2 containers found      ]
[         0 containers skipped    ]
[         2 containers started    ]
[         0 containers aborted    ]
[         2 containers successful ]
[         0 containers failed     ]
[         0 tests found           ]
[         0 tests skipped         ]
[         0 tests started         ]
[         0 tests aborted         ]
[         0 tests successful      ]
[         0 tests failed          ]
Mr P
  • 11
  • 2
  • Do you have compiled the `.java` files? The `ex1/test` directory does not contain any `.class` files (but the `out` directory have some). – Progman Dec 29 '19 at 20:15
  • tried to change the path to ex1/out/test no changes. – Mr P Dec 29 '19 at 21:39
  • Please [edit] your question to include the output of running your JUnit execution with the `--details=verbose` option. – Progman Dec 29 '19 at 21:45
  • I've added a verbose run – Mr P Dec 29 '19 at 22:51
  • Maybe you need to work with the `-cp` setting, see https://stackoverflow.com/questions/45869932/unable-to-run-tests-with-junit5-console-launcher – Progman Dec 29 '19 at 22:58

1 Answers1

3

JUnit Jupiter (shipped with "JUnit 5") and JUnit Vintage (executes "JUnit 3+4" tests) don't support the --select-directory option offered by the JUnit Platform (part of "JUnit 5"). Both engines only support class-based test selection, which means that test classes must be available on the class or module path at runtime.

Using paths from your directory tree, this standalone command should work:

java
  -jar junit-platform-console-standalone-${VERSION}.jar
  --class-path ex1/out/test
  --class-path ex1/out/production
  --scan-class-path

Assuming that you compiled all sources within IntelliJ IDEA.

Here's a hint how to compile your production/tests sources on the command line: How to launch JUnit 5 (Platform) from the command line (without Maven/Gradle)?

Sormuras
  • 8,491
  • 1
  • 38
  • 64
  • tried to run java -jar ex1/lib/junit-platform-console-standalone-1.6.0-M1.jar--select-directory="./ex1/test" --class-path ex1/out/test --class-path ex1/out/production --scan-class-path **no changes** – Mr P Dec 30 '19 at 13:35
  • Drop the "--select-directory..." option. Scanning and selecting at the same time is not supported. The launcher will print something like: "Scanning the classpath and using explicit selectors at the same time is not supported" – Sormuras Jan 02 '20 at 04:21