ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ivan Bessonov (JIRA)" <j...@apache.org>
Subject [jira] [Created] (IGNITE-11323) Reduce boilerplate "System.setProperty" code in tests
Date Thu, 14 Feb 2019 15:27:00 GMT
Ivan Bessonov created IGNITE-11323:

             Summary: Reduce boilerplate "System.setProperty" code in tests
                 Key: IGNITE-11323
                 URL: https://issues.apache.org/jira/browse/IGNITE-11323
             Project: Ignite
          Issue Type: Test
            Reporter: Ivan Bessonov
            Assignee: Ivan Bessonov

There are many examples in tests where some property gets new value in "beforeTestsStarted"/"beforeTest"/"beginning
of test method" and then gets its previous value in "afterTestsStopped"/"afterTest"/"finally
block of test method". This approach leads to excessive code that can be avoided.

I suggest implementing annotation "WithSystemProperty" (name is the subject to discussion)
that will allow us to write this:
@WithSystemProperty(key = IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK, value = "true")
public void testSkipCheckConsistencyFlagEnabled() throws Exception {
instead of this:
public void testSkipCheckConsistencyFlagEnabled() throws Exception {
    String backup = System.setProperty(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK, "true");

    try {
    finally {
        if (backup != null)
            System.setProperty(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK, backup);

There's also has to be ability to use this annotation on test class so new value of system
properties will be used in all of its test methods.

This message was sent by Atlassian JIRA

View raw message