[
https://issues.apache.org/jira/browse/CASSANDRA-18066?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17687061#comment-17687061
]
Stefan Miklosovic commented on CASSANDRA-18066:
-----------------------------------------------
So ... it will be a little bit more complicated. The correct calling of these
methods is:
{code}
before class BaseClass
before class MyTest
before BaseClass
before MyTest
after MyTest
after BaseClass
after class MyTest
after class BaseClass
{code}
The problem is that when before/after methods (static or normal) are called
same as these in the base class, the base methods will really not be invoked.
Basically, if it overrides, the base will not be called. There are some cases
when a test class is overriding (same method name) and sometimes it does not
etc.
I will try to dig deeper here.
> Server should be started in @Before rather than @BeforeClass in CQLTester
> -------------------------------------------------------------------------
>
> Key: CASSANDRA-18066
> URL: https://issues.apache.org/jira/browse/CASSANDRA-18066
> Project: Cassandra
> Issue Type: Bug
> Components: Test/unit
> Reporter: Jacek Lewandowski
> Assignee: Stefan Miklosovic
> Priority: Normal
> Fix For: 4.x
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> I can see that there is some misunderstanding in the project of
> {{@BeforeClass}} annotated methods.
> Given we have a static method {{@BeforeClass static void initA()}} in
> {{CQLTester}} and {{@BeforeClass static void initB()}} in {{SomeTestClass
> extends CQLTester}}, it will run like the following:
> 1. static initializer of {{CQLTester}}
> 2. {{initA()}}
> 3. static initializer of {{SomeTestClass}}
> 4. {{initB()}}
> Since the server is started in (2), there is essentially no way to
> consistently set startup properties or configuration of
> {{DatabaseDescriptor}} in {{SomeTestClass}} so that the starting server can
> pick it consistently. That is, if something works, it is just because some
> server class has not been used yet, but this actually cannot be guaranteed.
> When I look in the code, it seems like the understanding of JUnit was that if
> {{initB()}} is defined, then {{initA()}} is not called, but this is not true.
> Therefore, I propose to move the server initialization from {{initA()}} (call
> to {{SchemaLoader.prepareServer()}} to a method annotated with {{@Before}} in
> {{CQLTester}} so that the server is started with the first test case. Then,
> we will be sure that call to {{initB()}} will happen before the server is
> initialized and we will be able to set configuration consistently.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]