Skip to content

Commit

Permalink
Simplified tests from NatWithoutEditorBehavoirTests eclipse-4diac#377
Browse files Browse the repository at this point in the history
For better readability and maintainability, the test variables from the
method operationsInitialzation() with Annotation @beforeeach have been
moved to a constructor.

Addresses eclipse-4diac#377
  • Loading branch information
Andrearium committed Sep 16, 2024
1 parent 292af44 commit 3052111
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3052111

Please sign in to comment.