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

TestNG Dataprovider parameters cannot be used in <variables> block #298

Closed
gucce opened this Issue Oct 25, 2017 · 0 comments

Comments

Projects
None yet
2 participants
@gucce
Contributor

gucce commented Oct 25, 2017

Problem

When using a TestNG Dataprovider, the corresponding Citrus variables are only usable in the <actions> block but not in the <variables> block.

Example

TestNG Definition

public class IT_Some_Test extends AbstractTestNGCitrusTest {

    @DataProvider(name = "someDataProvider")
    public Object[][] someDataProvider() {
        return new Object[][]{
                new Object[]{"some_value"},
        };
    }

    @Test(dataProvider = "someDataProvider")
    @CitrusParameters({"someVariable"})
    @CitrusXmlTest(name = "IT_Some_Test")
    @SuppressWarnings("unused")
    public void test(String someVariable) {
    }

}

Citrus XML Test

<testcase name="IT_Some_Test">
    <variables>
        <!-- At this point the TestNG parameter 'someVariable' is not set yet. The test will fail. -->
        <variable name="otherVariable" value="${someVariable}"/>
    </variables>

    <actions>
        <create-variables>
            <!-- At this point the TestNG parameter 'someVariable' is set -->
            <variable name="otherVariable" value="${someVariable}"/>
        </create-variables>
    </actions>
</testcase>

Solution

Set TestNG parameters in TestContext before any other variables are set (which may depend on TestNG parameters).

@gucce gucce added the Type: Bug label Oct 25, 2017

@christophd christophd added the READY label Oct 25, 2017

@christophd christophd added this to the v2.7.3 milestone Oct 25, 2017

@christophd christophd added IN PROGRESS and removed READY labels Nov 13, 2017

@christophd christophd closed this in d8c1bc9 Dec 6, 2017

@christophd christophd removed the IN PROGRESS label Dec 6, 2017

christophd added a commit that referenced this issue Dec 6, 2017

Merge pull request #316 from FMAOuroboros/fix-xml-test-name
(#298) Fixed CitrusXmlTest reference
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment