-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Spark 3.5: Remove constructor from parameterized base class #9368
Conversation
Parameterized base classes should not have a constructor but rather have their parameters set via `@Parameter`. All other setup code should go into a `@BeforeEach` method to properly initialize the test environment
@@ -30,7 +29,7 @@ public abstract class CatalogTestBase extends TestBaseWithCatalog { | |||
|
|||
// these parameters are broken out to avoid changes that need to modify lots of test suites | |||
@Parameters(name = "catalogName = {0}, implementation = {1}, config = {2}") | |||
public static Object[][] parameters() { | |||
protected static Object[][] parameters() { |
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.
JUnit4 required this to be public but for JUnit5 we can make it protected
protected static Object[][] parameters() { | ||
return new Object[][] { | ||
{ | ||
SparkCatalogConfig.HADOOP.catalogName(), |
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.
all of the subclasses of this test that didn't specify any particular parameter were running with this configuration (this is also the configuration that was initialized in the default constructors in L70
@@ -50,7 +50,7 @@ public void removeTables() { | |||
sql("DROP TABLE IF EXISTS %s", tableName); | |||
} | |||
|
|||
@Test | |||
@TestTemplate |
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.
all of the subclasses of TestBaseWithCatalog
are parameterized tests
@@ -39,11 +38,6 @@ | |||
|
|||
public class TestSparkStagedScan extends CatalogTestBase { | |||
|
|||
public TestSparkStagedScan( |
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.
this and the class below were running with the three different catalog configurations defined in CatalogTestBase
and I've verified that this is still the case
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.
Great improvement @nastra! Looking good
After reviewing/merging #9342 I realized that parameterized base classes should not have a constructor but rather have their parameters set via
@Parameter
. All other setup code should go into a@BeforeEach
method to properly initialize the test environment