Add JUnit 5 unit tests for core DayTrader classes#3
Draft
alexlang74 wants to merge 1 commit intomainfrom
Draft
Conversation
Add 202 unit tests covering the most important classes: Entity beans (src/test/java/.../entities/): - AccountDataBeanTest: constructors, login/logout, equals/hashCode, toString - AccountProfileDataBeanTest: CRUD accessors, equals/hashCode, random instance - HoldingDataBeanTest: constructors, quoteID delegation, equals/hashCode - OrderDataBeanTest: isBuy/isSell/isOpen/isCompleted/isCancelled, cancel(), equals - QuoteDataBeanTest: all field accessors, equals/hashCode, random instance Utility classes (src/test/java/.../util/): - FinancialUtilsTest: computeGain, computeGainPercent, computeHoldingsTotal, HTML formatters - TradeConfigTest: runtime modes, max limits, order fees, random generators, setConfigParam - KeyBlockTest: size, sequential iteration, boundary conditions, unsupported operations - TimerStatTest: min/max/count/totalTime, seconds conversions, average computation Data beans (src/test/java/.../beans/): - MarketSummaryDataBeanTest: constructor, gainPercent computation, JSON output, toString - RunStatsDataBeanTest: all counter getters/setters, toString output Also adds to pom.xml: - junit-jupiter 5.10.1 (test scope) - javax.json 1.1.4 glassfish impl (test scope, for MarketSummaryDataBean.toJSON()) - maven-surefire-plugin 3.1.2 for JUnit 5 runner support Co-authored-by: Alexander Lang <alexlang@de.ibm.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a comprehensive JUnit 5 unit test suite for the most important classes in the DayTrader 8 application. The project had no automated tests before this change.
Changes
pom.xmljunit-jupiter 5.10.1(test scope)javax.json 1.1.4Glassfish reference implementation (test scope, required forMarketSummaryDataBean.toJSON())maven-surefire-plugin 3.1.2to enable the JUnit 5 platform runnerNew test files (
src/test/java/)Entity beans
AccountDataBeanTestlogin()/logout(), equals/hashCode,toString/toHTML, random instanceAccountProfileDataBeanTestHoldingDataBeanTestgetQuoteID()delegation toQuoteDataBean, equals/hashCode, random instanceOrderDataBeanTestisBuy/isSell/isOpen/isCompleted/isCancelled,cancel(), symbol delegation, equals/hashCodeQuoteDataBeanTestUtility classes
FinancialUtilsTestcomputeGain,computeGainPercent(including zero open balance),computeHoldingsTotal(null/empty/populated), HTML formattersTradeConfigTestsetConfigParam, constantsKeyBlockTestsize(), sequential forward iteration,hasPrevious/previous,nextIndex, unsupported operationsTimerStatTestData beans
MarketSummaryDataBeanTestgainPercentcaching,toJSON()keys,toString/toHTMLwith and without collections, random instanceRunStatsDataBeanTesttoStringoutputTotal: 202 tests — all passing.
Test selection rationale
Classes were selected based on: (1) centrality to the trading domain (entity beans used across all layers), (2) pure business logic with no container/EJB dependencies (making them straightforwardly unit-testable), and (3) non-trivial behaviour worth guarding (financial calculations, state machines in
OrderDataBean, key iteration inKeyBlock, configuration management inTradeConfig).