-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce module tests for GTFS-RT #5871
Introduce module tests for GTFS-RT #5871
Conversation
b4d5495
to
6abcd5f
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #5871 +/- ##
=============================================
+ Coverage 68.51% 68.54% +0.02%
- Complexity 16725 16732 +7
=============================================
Files 1918 1918
Lines 72734 72734
Branches 7456 7456
=============================================
+ Hits 49834 49854 +20
+ Misses 20329 20310 -19
+ Partials 2571 2570 -1 ☔ View full report in Codecov by Sentry. |
@leonardehrenfried I think the idea looks good! But in general I would prefer composition in favor of inheritance. Specifically if we ever want to test gtfs and siri together it would get clunky with an abstract base class. |
@habrahamsson-skanetrafiken I've changed the inheritance to composition. It's not super-elegant either but less bad than some other options. My intention is for the split between Siri and GTFS test environment to become unnecessary once I've extracted a common timetable snapshot manager. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we would want to merge the SiriEnv, the GtfsEnv and the RealtimeTestData into one class, then we could put two separate snapshot sources in the merged environment but make sure only one was initialized. And then throw a runtime exception if you try to call the gtfs methods on an environment where the siri snapshot source was initialized. I think this would work?
But maybe it's nice with the separation that we get now. I don't really have a strong opinion. So you can leave it as it is if you want.
I like the structure that the moduletests add!
Otherwise just some minor comments.
src/ext-test/java/org/opentripplanner/ext/siri/SiriRealtimeTestEnvironment.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opentripplanner/updater/trip/GtfsRealtimeTestEnvironment.java
Outdated
Show resolved
Hide resolved
private TransitModel transitModel; | ||
|
||
private final GtfsRealtimeFuzzyTripMatcher TRIP_MATCHER_NOOP = null; | ||
|
||
private final boolean fullDataset = false; | ||
private byte[] cancellation; | ||
private final boolean FULL_DATASET = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should be called NOT_FULL_DATASET
to make it clearer that we are setting the param to false in the call sites?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does "not full" mean? Partial ? I guess the underlying problem is that the input param i a boolean and not an enum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thomas is correct. I wanted to turn this boolean into an enum for many years. Do you want me to do that in this PR or another one?
src/test/java/org/opentripplanner/updater/trip/TimetableSnapshotSourceTest.java
Show resolved
Hide resolved
src/ext-test/java/org/opentripplanner/ext/siri/SiriRealtimeTestEnvironment.java
Outdated
Show resolved
Hide resolved
0a03b98
to
19b9ab9
Compare
ccb3903
to
22aa4b1
Compare
410284c
Summary
As discussed in the realtime working group meeting, this introduces module tests for the GTFS-RT realtime code. They are ports of the existing tests but have been converted to use @habrahamsson-skanetrafiken's test environment code. This results in faster test execution and a less confusing debugging experience.
To make this possible, I extracted the bulk of the test environment into a base class which is subclassed by both the Siri and GTFS-RT test to add a few specific methods.
Unit tests
Well... yes.
Documentation
Javadoc for each test case.