From 6043aa0434c4568f6bfb7fefbf8f0835c90fc43a Mon Sep 17 00:00:00 2001 From: Andrea Zoitl Date: Mon, 9 Sep 2024 10:55:17 +0200 Subject: [PATCH] Simplified tests from NatWithoutEditorBehavoirTests #377 For better readability and maintainability, the test variables from the method operationsInitialzation() with Annotation @BeforeEach have been moved to a constructor. Addresses https://github.com/eclipse-4diac/4diac-ide/issues/377 --- .../test/ui/fbtype/AttributesTabTests.java | 8 +++++--- .../ide/test/ui/fbtype/ConstantsTabTests.java | 8 +++++--- .../test/ui/fbtype/DataTypeEditorTests.java | 7 ++++--- .../ui/fbtype/FunctionBlocksTabTests.java | 7 ++++--- .../NatTableWithoutEditorBehaviorTests.java | 20 ++++++++++++++----- .../test/ui/fbtype/VarInternalsTabTests.java | 7 ++++--- 6 files changed, 37 insertions(+), 20 deletions(-) diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/AttributesTabTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/AttributesTabTests.java index 5ddbfed097..2e94c436a5 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/AttributesTabTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/AttributesTabTests.java @@ -27,6 +27,11 @@ // Have to look into the table as this has so much different behavior public class AttributesTabTests extends NatTableWithoutEditorBehaviorTests { + + public AttributesTabTests() { + super(UITestNamesHelper.ATTRIBUTE1, UITestNamesHelper.ATTRIBUTE2, UITestNamesHelper.ATTRIBUTE3); + } + /** * Performs necessary tasks to make environment for testing the operations on * DataType Editor Table. @@ -38,9 +43,6 @@ public class AttributesTabTests extends NatTableWithoutEditorBehaviorTests { @Override @BeforeEach public void operationsInitialization() { - TESTVAR1 = UITestNamesHelper.ATTRIBUTE1; - TESTVAR2 = UITestNamesHelper.ATTRIBUTE2; - TESTVAR3 = UITestNamesHelper.ATTRIBUTE3; final SWTBotFBType fbTypeBot = new SWTBotFBType(bot); fbTypeBot.createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, UITestNamesHelper.TEMPLATEBASIC); diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/ConstantsTabTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/ConstantsTabTests.java index c811a2f8d7..8f0f058ed0 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/ConstantsTabTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/ConstantsTabTests.java @@ -27,12 +27,14 @@ public class ConstantsTabTests extends NatTableWithoutEditorBehaviorTests { + public ConstantsTabTests() { + super(UITestNamesHelper.INTERNALCONSTVAR1, UITestNamesHelper.INTERNALCONSTVAR2, + UITestNamesHelper.INTERNALCONSTVAR3); + } + @Override @BeforeEach public void operationsInitialization() { - TESTVAR1 = UITestNamesHelper.INTERNALCONSTVAR1; - TESTVAR2 = UITestNamesHelper.INTERNALCONSTVAR2; - TESTVAR3 = UITestNamesHelper.INTERNALCONSTVAR3; final SWTBotFBType fbTypeBot = new SWTBotFBType(bot); fbTypeBot.createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, UITestNamesHelper.TEMPLATEBASIC); diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/DataTypeEditorTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/DataTypeEditorTests.java index a07c7c5189..ef4aa8c960 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/DataTypeEditorTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/DataTypeEditorTests.java @@ -25,12 +25,13 @@ public class DataTypeEditorTests extends NatTableWithoutEditorBehaviorTests { + public DataTypeEditorTests() { + super(UITestNamesHelper.VAR1, UITestNamesHelper.VAR2, UITestNamesHelper.VAR3); + } + @Override @BeforeEach public void operationsInitialization() { - TESTVAR1 = UITestNamesHelper.VAR1; - TESTVAR2 = UITestNamesHelper.VAR2; - TESTVAR3 = UITestNamesHelper.VAR3; final SWTBotFBType fbTypeBot = new SWTBotFBType(bot); fbTypeBot.createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/FunctionBlocksTabTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/FunctionBlocksTabTests.java index 3d519f537f..62bff651cb 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/FunctionBlocksTabTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/FunctionBlocksTabTests.java @@ -31,12 +31,13 @@ public class FunctionBlocksTabTests extends NatTableWithoutEditorBehaviorTests { + public FunctionBlocksTabTests() { + super(UITestNamesHelper.INTERNALFB1, UITestNamesHelper.INTERNALFB2, UITestNamesHelper.INTERNALFB3); + } + @Override @BeforeEach public void operationsInitialization() { - TESTVAR1 = UITestNamesHelper.INTERNALFB1; - TESTVAR2 = UITestNamesHelper.INTERNALFB2; - TESTVAR3 = UITestNamesHelper.INTERNALFB3; final SWTBotFBType fbTypeBot = new SWTBotFBType(bot); fbTypeBot.createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, UITestNamesHelper.TEMPLATEBASIC); diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/NatTableWithoutEditorBehaviorTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/NatTableWithoutEditorBehaviorTests.java index 14098e98ec..17b8de2b8e 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/NatTableWithoutEditorBehaviorTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/NatTableWithoutEditorBehaviorTests.java @@ -29,9 +29,19 @@ public class NatTableWithoutEditorBehaviorTests extends Abstract4diacUITests { protected SWTBot4diacNatTable swt4diacNatTable; protected NatTable natTable; - protected String TESTVAR1 = "TESTVAR1"; //$NON-NLS-1$ - protected String TESTVAR2 = "TESTVAR2"; //$NON-NLS-1$ - protected String TESTVAR3 = "TESTVAR3"; //$NON-NLS-1$ + private final String testVar1; + private final String testVar2; + private final String testVar3; + + protected NatTableWithoutEditorBehaviorTests() { + this("TESTVAR1", "TESTVAR2", "TESTVAR3"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + + protected NatTableWithoutEditorBehaviorTests(final String testVar1, final String testVar2, final String testVar3) { + this.testVar1 = testVar1; + this.testVar2 = testVar2; + this.testVar3 = testVar3; + } /** * Performs necessary tasks to make environment for testing the operations on @@ -103,7 +113,7 @@ public void changeVariableNameWithButton() { */ @Test public void tryToChangeNameOfVariableWithExistingName() { - new SWTBotNatTable(bot, swt4diacNatTable).changeNameWithExistingName(2, TESTVAR1, TESTVAR2); + new SWTBotNatTable(bot, swt4diacNatTable).changeNameWithExistingName(2, testVar1, testVar2); } /** @@ -115,7 +125,7 @@ public void tryToChangeNameOfVariableWithExistingName() { */ @Test public void tryToSetInValidName() { - new SWTBotNatTable(bot, swt4diacNatTable).setInvalidName(1, UITestNamesHelper.IF, TESTVAR1); + new SWTBotNatTable(bot, swt4diacNatTable).setInvalidName(1, UITestNamesHelper.IF, testVar1); } /** diff --git a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/VarInternalsTabTests.java b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/VarInternalsTabTests.java index 2391bbc1f0..20e24679e7 100644 --- a/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/VarInternalsTabTests.java +++ b/tests/org.eclipse.fordiac.ide.test.ui/src/org/eclipse/fordiac/ide/test/ui/fbtype/VarInternalsTabTests.java @@ -29,12 +29,13 @@ public class VarInternalsTabTests extends NatTableWithoutEditorBehaviorTests { + public VarInternalsTabTests() { + super(UITestNamesHelper.INTERNALVAR1, UITestNamesHelper.INTERNALVAR2, UITestNamesHelper.INTERNALVAR3); + } + @Override @BeforeEach public void operationsInitialization() { - TESTVAR1 = UITestNamesHelper.INTERNALVAR1; - TESTVAR2 = UITestNamesHelper.INTERNALVAR2; - TESTVAR3 = UITestNamesHelper.INTERNALVAR3; final SWTBotFBType fbTypeBot = new SWTBotFBType(bot); fbTypeBot.createFBType(UITestNamesHelper.PROJECT_NAME, UITestNamesHelper.FBT_TEST_PROJECT2, UITestNamesHelper.TEMPLATEBASIC);