Skip to content
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

SNOW-1693588 Upgrade to JUnit5 #1909

Merged
merged 110 commits into from
Nov 27, 2024
Merged

Conversation

sfc-gh-astachowski
Copy link
Collaborator

@sfc-gh-astachowski sfc-gh-astachowski commented Oct 4, 2024

Overview

SNOW-1693588 upgraded all tests to junit5. There are a lot of changes, but most are of following types:

  • Changed imports to junit5 (@Test annotation, Assumptions, Assertions)
    • Note: junit5 assertions take error message as last argument instead of first, causing a lot of changes.
  • Changed annotations to their 1:1 counterparts ( @Before to @BeforeEach, @BeforeClass to @BeforeAll etc.)
  • Changed parametrisation from junit4 style (class level) to junit5 style (method level). This means in most cases, that any constructors with arguments have been removed and the arguments are instead passed directly to the tests.
    • As a con, this means some @BeforeClass annotations could not be translated to junit5, as the fields they depend on no longer exist. As a result, in those cases relevant functions are now called at the beginning of each test. (Could be remedied later I believe)
  • Changed temporary folders from junit4 style to junit5 style (@Rule to @TempDir)
    • Moved several input/output streams to try-with-resources statements (while seemingly unrelated, leaving them open was causing some issues with @TempDir on windows)
  • Changed conditional enable/disable annotations to junit5 style
    • Moved static functions from deleted Conditional ignore rules to new AssumptionUtils class
  • Changed from junit4 @Category annotations to junit5 @Tag
  • No longer asserting throws with annotations, using assertThrows instead.
  • In many tests added logic to restore system properties after test execution (required now, because junit5 runs tests in different order than junit4, revealing errors like this).

Pre-review self checklist

  • PR branch is updated with all the changes from master branch
  • The code is correctly formatted (run mvn -P check-style validate)
  • New public API is not unnecessary exposed (run mvn verify and inspect target/japicmp/japicmp.html)
  • The pull request name is prefixed with SNOW-XXXX:
  • Code is in compliance with internal logging requirements

@sfc-gh-astachowski sfc-gh-astachowski requested a review from a team as a code owner October 4, 2024 08:58
# Conflicts:
#	src/test/java/net/snowflake/client/jdbc/ClientMemoryLimitParallelIT.java
#	src/test/java/net/snowflake/client/jdbc/ConnectionIT.java
#	src/test/java/net/snowflake/client/jdbc/ConnectionLatestIT.java
#	src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataIT.java
#	src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataLatestIT.java
#	src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataResultsetIT.java
#	src/test/java/net/snowflake/client/jdbc/MultiStatementLatestIT.java
#	src/test/java/net/snowflake/client/jdbc/OpenGroupCLIFuncIT.java
#	src/test/java/net/snowflake/client/jdbc/PreparedMultiStmtArrowIT.java
#	src/test/java/net/snowflake/client/jdbc/PreparedMultiStmtIT.java
#	src/test/java/net/snowflake/client/jdbc/SnowflakeDriverLatestIT.java
#	src/test/java/net/snowflake/client/jdbc/SnowflakeUtilTest.java
#	src/test/java/net/snowflake/client/jdbc/StreamLatestIT.java
pom.xml Outdated Show resolved Hide resolved
src/test/java/net/snowflake/client/TestUtil.java Outdated Show resolved Hide resolved
# Conflicts:
#	src/test/java/net/snowflake/client/config/SFConnectionConfigParserTest.java
@sfc-gh-astachowski sfc-gh-astachowski merged commit a20f2cf into master Nov 27, 2024
137 of 142 checks passed
@sfc-gh-astachowski sfc-gh-astachowski deleted the SNOW-1693588-upgrade-to-junit5 branch November 27, 2024 14:13
@github-actions github-actions bot locked and limited conversation to collaborators Nov 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants