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

[#266] clear test context after run #268

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.xceptance.neodymium.junit5.filtering.FilterTestMethodCallback;
import com.xceptance.neodymium.junit5.filtering.WipTestMethodCallback;
import com.xceptance.neodymium.junit5.testdata.TestdataCallback;
import com.xceptance.neodymium.util.Neodymium;

public class TemplateInvocationContext implements TestTemplateInvocationContext
{
Expand Down Expand Up @@ -40,6 +41,7 @@ public String getDisplayName(int invocationIndex)
@Override
public List<Extension> getAdditionalExtensions()
{
Neodymium.clearThreadContext();
List<Extension> extentions = new LinkedList<>();
if (browser != null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.xceptance.neodymium.junit4.testclasses.data;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

import com.xceptance.neodymium.junit4.NeodymiumRunner;
import com.xceptance.neodymium.util.DataUtils;

@RunWith(NeodymiumRunner.class)
public class ClearedContextBetweenMethods
{
@Test
public void test()
{
if (DataUtils.asString("testId").equals("fist set"))
{
Assert.assertEquals("Test data is not matching the test expectations", "val1", DataUtils.asString("key1"));
Assert.assertEquals("Test data is not matching the test expectations", "val2", DataUtils.asString("key2"));
}
else
{
Assert.assertEquals("Test data is not overwritten", "new val", DataUtils.asString("key1"));
Assert.assertNull("Test data context is not cleared", DataUtils.asString("key2", null));
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.xceptance.neodymium.junit5.testclasses.data;

import org.junit.Assert;

import com.xceptance.neodymium.junit5.NeodymiumTest;
import com.xceptance.neodymium.util.DataUtils;

public class CleanedContextBetweenMethods
{
@NeodymiumTest
public void test()
{
if (DataUtils.asString("testId").equals("fist set"))
{
Assert.assertEquals("Test data is not matching the test expectations", "val1", DataUtils.asString("key1"));
Assert.assertEquals("Test data is not matching the test expectations", "val2", DataUtils.asString("key2"));
}
else
{
Assert.assertEquals("Test data is not overwritten", "new val", DataUtils.asString("key1"));
Assert.assertNull("Test data context is not cleared", DataUtils.asString("key2", null));
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"testId": "fist set",
"key1": "val1",
"key2": "val2"
},
{
"testId": "second set",
"key1": "new val"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"testId": "fist set",
"key1": "val1",
"key2": "val2"
},
{
"testId": "second set",
"key1": "new val"
}
]