From 08393b3abaa4f69a16abcd92c399b75b76b8243c Mon Sep 17 00:00:00 2001 From: Bernd Weigel Date: Wed, 10 Jul 2024 12:57:15 +0200 Subject: [PATCH 1/3] [#182] removed remaining config files --- config/ai.properties | 78 ------------------------------- config/visualassertion.properties | 72 ---------------------------- 2 files changed, 150 deletions(-) delete mode 100644 config/ai.properties delete mode 100644 config/visualassertion.properties diff --git a/config/ai.properties b/config/ai.properties deleted file mode 100644 index 0b314ef67..000000000 --- a/config/ai.properties +++ /dev/null @@ -1,78 +0,0 @@ -####################################################################### -#The possible properties and their default values are: -#neodymium.ai.TESTCASE_BOUND = true -#neodymium.ai.TESTCASE_NAME = unbound -#neodymium.ai.TRAINING = true -#neodymium.ai.WAITINGTIME = 1000 -#neodymium.ai.INTENDED_PERCENTAGE_MATCH = 0.80 -#neodymium.ai.USE_COLOR_FOR_COMPARISON = true -#neodymium.ai.USE_ORIGINAL_SIZE = true -#neodymium.ai.IMAGE_HEIGHT = 800 -#neodymium.ai.IMAGE_WIDTH = 600 -#neodymium.ai.PERCENTAGE_DIFFERENCE = 0.2 -#neodymium.ai.LEARNING_RATE = 0.2 -#neodymium.ai.FORMAT = png -######################################################################### - -# Global flag to turn visual assertions off, nothing will be done, all code is skipped -neodymium.ai.enabled = false - -# Result directory for the image output, relative to the test suite -# main directory -neodymium.ai.resultDirectory = results/ai - -# ID for the current environment that hosts the AI module. -# The ID is used in the creation of the folder structure for the results. -neodymium.ai.ID = localmachine - -# Bound to the chosen test case or not. -# If the flag is true the name of the used test case will be used for localization. -# The value false let the network unbound and can be used for different testcases -neodymium.ai.TESTCASE_BOUND = true - -# Possibility to name the unbound folder. -neodymium.ai.TESTCASE_NAME = name - -# Set the state of the network to training -# neodymium.ai.TRAINING = true -# or to classification mode. -# neodymium.ai.TRAINING = false -# In training mode all data under the specific name of the network, in the training directory "used for training" -# will be used for training the network. Otherwise the new screenshots get sort in recognized and unrecognized. -neodymium.ai.TRAINING = false - -# The time the program waits for a page to load before it takes the screenshot (in ms). -neodymium.ai.WAITINGTIME = 1000 - -# Desired percentage value for the self test, until this barrier is confirmed the network will -# still learn (use several screenshots which where already seen) -# procedural value between 0 - 1.00 percent -neodymium.ai.INTENDED_PERCENTAGE_MATCH = 0.80 - -# Color will also be used for image comparison, useful for websites with much almost same size content. -# Content is every element on the website. -neodymium.ai.USE_COLOR_FOR_COMPARISON = true - -# Parameter for enabling down scaling from screenshots or not, this can drastically change -# the performance of the algorithm -neodymium.ai.USE_ORIGINAL_SIZE = true - -# value for the height of the image, only used if USE_ORIGINAL_SIZE is false -neodymium.ai.IMAGE_HEIGHT = 800 - -# value for the width of the image, only used if USE_ORIGINAL_SIZE is false -neodymium.ai.IMAGE_WIDTH = 1200 - -# procedural value for the difference level used for comparing the screenshots to another -neodymium.ai.PERCENTAGE_DIFFERENCE = 0.2 - -# value for the learning algorithm allowed values are between 0.0 - 1.0 -# affect the learn speed of the neural network, greater values are for faster learning -# but the accuracy can decrease with higher values -neodymium.ai.LEARNING_RATE = 0.3 - -# image format for saving -# compatible formats are jpg, png, bmp, jpeg -neodymium.ai.FORMAT = png -######################################################################### - diff --git a/config/visualassertion.properties b/config/visualassertion.properties deleted file mode 100644 index 63a9d83a7..000000000 --- a/config/visualassertion.properties +++ /dev/null @@ -1,72 +0,0 @@ -# Global flag to turn visual assertions off, nothing will be done, all code is skipped -neodymium.visualassertion.enabled=true - -# Result directory for the image output, relative to the test suite -# main directory -neodymium.visualassertion.resultDirectory=results/visualassertion - -## ID for the current environment that hosts the visualassertion module. -## The ID is used in the creation of the folder structure for the results. -## This should be used like this for now, because different environment create different screenshot which might cause an assertion to -## fail, even if the page is still valid. -neodymium.visualassertion.ID=localmachine - -# The time the program waits for a page to load before it takes the screenshot -neodymium.visualassertion.waitingTime=1000 - -# These parameters determine the width and height of the blocks used for marking and masking. While the size of the blocks during marking -# is purely cosmetic, for masking it causes an increase in the masked area -neodymium.visualassertion.mark.blocksize.x=10 -neodymium.visualassertion.mark.blocksize.y=10 - -## How the marking should look like - marking type -# box: Draw a box with blocksize, the difference box might not be in the center, it is effectively -# the comparison box used in the algorithm. -# marker: Use yellow highlighter and mark different pixels in red too -neodymium.visualassertion.mark.type=marker - -# The algorithm used for the determination of layout differences. -# -# FUZZY: Uses color and pixel difference thresholds that determine when the difference in -# a block of pixels is a error. First the difference in color between each pixel in a block -# is checked, if the number of pixels, for which the color difference is too high, -# exceeds the number limit in one block, those differences are seen as error and marked. -# -# COLORFUZZY: Only uses a color threshold to determine a layout error. One detected difference will -# fail the test. Based on a comparison algorithm from http://www.compuphase.com/cmetric.htm . -# The algorithm is based on experiments with people, not theoretics. -# EXACT: Does not use any thresholds, checks for exact pixel by pixel match -neodymium.visualassertion.algorithm=FUZZY - -# Color threshold for COLORFUZZY and FUZZY. Takes a value between 0 and 1 that stands for the -# color difference in percent between two pixels. 0 is equal to an exact pixel by pixel comparison, where -# no difference is allowed. -neodymium.visualassertion.tolerance.colors=0.1 - -# Number of pixel differences threshold for FUZZY in one comparison block. Takes a value between 0 and 1 that -# stands for the percentage of different pixels in one block. 0 is equal to an exact pixel by pixel comparison. -# 0.1 would mean that 10% of pixels can be different. -neodymium.visualassertion.tolerance.pixels=0.1 - -# The side length of one comparison block for the FUZZY algorithm. Takes integer values that stand for the number of -# pixels per side. The values provide a way to tolerate shifts of small objects, especially text. The values divide the image -# into squares with a width=height=value. -> Block = xy * xy -neodymium.visualassertion.fuzzy.blocksize.xy=10 - -# Flag whether a image shall be created, which displays the found differences in grayscale on a black background -neodymium.visualassertion.onFailure.createDifferenceImage=true - -# Flag whether the training mode of the image mask is enabled. While in training mode the module saves found differences -# in a mask, which can be used to train the algorithms to ignore valid dynamic content changes in the images. Additional training -# runs adjust the mask further. -neodymium.visualassertion.trainingsMode=true - -# Flag whether the masked area shall be increased to better mask content changes that are valid -neodymium.visualassertion.mask.close=false - -# Size of the masking area when a pixel is found to be different when in training mode. Image this as a black stamp in -# this size. The middle of the stamp is where the difference pixel is, so you get a nice area around it marked to be ignored as -# well. -neodymium.visualassertion.mask.close.width=10 -neodymium.visualassertion.mask.close.height=10 - From 7d48d09973f682a65522fee1c1d7063b70b34602 Mon Sep 17 00:00:00 2001 From: Olha Omelianchuk Date: Wed, 10 Jul 2024 13:57:47 +0200 Subject: [PATCH 2/3] [#266] clear test context after run --- .../junit5/TemplateInvocationContext.java | 2 ++ .../data/ClearedContextBetweenMethods.java | 28 +++++++++++++++++++ .../data/CleanedContextBetweenMethods.java | 25 +++++++++++++++++ .../data/CleanedContextBetweenMethods.json | 11 ++++++++ .../data/CleanedContextBetweenMethods.json | 11 ++++++++ 5 files changed, 77 insertions(+) create mode 100644 src/test/java/com/xceptance/neodymium/junit4/testclasses/data/ClearedContextBetweenMethods.java create mode 100644 src/test/java/com/xceptance/neodymium/junit5/testclasses/data/CleanedContextBetweenMethods.java create mode 100644 src/test/resources/com/xceptance/neodymium/junit4/testclasses/data/CleanedContextBetweenMethods.json create mode 100644 src/test/resources/com/xceptance/neodymium/junit5/testclasses/data/CleanedContextBetweenMethods.json diff --git a/src/main/java/com/xceptance/neodymium/junit5/TemplateInvocationContext.java b/src/main/java/com/xceptance/neodymium/junit5/TemplateInvocationContext.java index 3ec39a4bd..79b7ba609 100644 --- a/src/main/java/com/xceptance/neodymium/junit5/TemplateInvocationContext.java +++ b/src/main/java/com/xceptance/neodymium/junit5/TemplateInvocationContext.java @@ -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 { @@ -40,6 +41,7 @@ public String getDisplayName(int invocationIndex) @Override public List getAdditionalExtensions() { + Neodymium.clearThreadContext(); List extentions = new LinkedList<>(); if (browser != null) { diff --git a/src/test/java/com/xceptance/neodymium/junit4/testclasses/data/ClearedContextBetweenMethods.java b/src/test/java/com/xceptance/neodymium/junit4/testclasses/data/ClearedContextBetweenMethods.java new file mode 100644 index 000000000..f390ea8aa --- /dev/null +++ b/src/test/java/com/xceptance/neodymium/junit4/testclasses/data/ClearedContextBetweenMethods.java @@ -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)); + } + } + +} diff --git a/src/test/java/com/xceptance/neodymium/junit5/testclasses/data/CleanedContextBetweenMethods.java b/src/test/java/com/xceptance/neodymium/junit5/testclasses/data/CleanedContextBetweenMethods.java new file mode 100644 index 000000000..24ccf09f7 --- /dev/null +++ b/src/test/java/com/xceptance/neodymium/junit5/testclasses/data/CleanedContextBetweenMethods.java @@ -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)); + } + } + +} diff --git a/src/test/resources/com/xceptance/neodymium/junit4/testclasses/data/CleanedContextBetweenMethods.json b/src/test/resources/com/xceptance/neodymium/junit4/testclasses/data/CleanedContextBetweenMethods.json new file mode 100644 index 000000000..31619e85f --- /dev/null +++ b/src/test/resources/com/xceptance/neodymium/junit4/testclasses/data/CleanedContextBetweenMethods.json @@ -0,0 +1,11 @@ +[ + { + "testId": "fist set", + "key1": "val1", + "key2": "val2" + }, + { + "testId": "second set", + "key1": "new val" + } +] diff --git a/src/test/resources/com/xceptance/neodymium/junit5/testclasses/data/CleanedContextBetweenMethods.json b/src/test/resources/com/xceptance/neodymium/junit5/testclasses/data/CleanedContextBetweenMethods.json new file mode 100644 index 000000000..31619e85f --- /dev/null +++ b/src/test/resources/com/xceptance/neodymium/junit5/testclasses/data/CleanedContextBetweenMethods.json @@ -0,0 +1,11 @@ +[ + { + "testId": "fist set", + "key1": "val1", + "key2": "val2" + }, + { + "testId": "second set", + "key1": "new val" + } +] From 3015ea1285fa55829ea292fa0f328222d63932d9 Mon Sep 17 00:00:00 2001 From: Bernd Weigel Date: Mon, 15 Jul 2024 16:06:30 +0200 Subject: [PATCH 3/3] Update to hotfix 5.0.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 89a817198..d110f586c 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.xceptance neodymium-library - 5.0.0 + 5.0.1 neodymium-library https://github.com/Xceptance/neodymium-library