averbraeck / opentrafficsim

Open Source Multi-Level Traffic Simulator
BSD 3-Clause "New" or "Revised" License
28 stars 8 forks source link

Unit tests need to be updated #62

Open averbraeck opened 1 year ago

averbraeck commented 1 year ago

When running unit tests on OTS, there are many failures. Some of the mock() methods with Mockito don't work (e.g., because they mock a final method). Also, unit tests fail because the 'contract' of the methods has changed.

averbraeck commented 1 year ago

An example of the problem is that Gtu is now a class, with a final getSimulator() implementation, instead of an interface with a public getSimulator() definition. In order for Mockito to mock this method, add a file called mockito-extensions to /src/test/resources of the projects with this problem, with one line:

mock-maker-inline

and update the Mockito version to 5.x.

averbraeck commented 1 year ago

In OdAppliertest in ots-core, the test public void gtuFractionTest() does not work, and stops with a NullPointerException. I do not understand enough of the OdApplier to repair the test. @WJSchakel : can you take a look (it's not urgent).

WJSchakel commented 1 year ago

@averbraeck the test was missing characteristics generators, which are no longer given by default in OdOptions as they rely on default GTU types etc. The test is fixed now.

WJSchakel commented 1 year ago

And now the @Test is also uncommented (it got commented after I merged changes before committing).

averbraeck commented 1 year ago

Thanks! It works. All other issues also tackled (although there are still quite a few tests of which parts were already commented out). New version of OTS will be released this afternoon.