Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Hohenegger2015-09-19 12:19:11 -0400
committerMax Hohenegger2015-09-22 07:18:51 -0400
commit9088b6b19b49de5a070607a14e9afb91c4568ed4 (patch)
tree217d780915615fb1622cd8e744dd3deb958b7c15
parent9a8d4c9b9856abe9b3e19a89d1a08773d93bd517 (diff)
downloadegit-9088b6b19b49de5a070607a14e9afb91c4568ed4.tar.gz
egit-9088b6b19b49de5a070607a14e9afb91c4568ed4.tar.xz
egit-9088b6b19b49de5a070607a14e9afb91c4568ed4.zip
Refactored feature finish UI tests to reduce redundancy
Change-Id: I4f70f569736d171eddfc11088bb210939eede659 Signed-off-by: Max Hohenegger <eclipse@hohenegger.eu>
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractFeatureFinishHandlerTest.java109
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureFinishKeepBranchHandlerTest.java61
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureFinishSquashHandlerTest.java40
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureStartFinishHandlerTest.java82
4 files changed, 123 insertions, 169 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractFeatureFinishHandlerTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractFeatureFinishHandlerTest.java
new file mode 100644
index 000000000..1377d4008
--- /dev/null
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractFeatureFinishHandlerTest.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (C) 2015, Max Hohenegger <eclipse@hohenegger.eu>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.egit.ui.gitflow;
+
+import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellIsActive;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.egit.core.op.BranchOperation;
+import org.eclipse.egit.gitflow.op.InitOperation;
+import org.eclipse.egit.gitflow.ui.Activator;
+import org.eclipse.egit.gitflow.ui.internal.JobFamilies;
+import org.eclipse.egit.gitflow.ui.internal.UIText;
+import org.eclipse.egit.ui.test.ContextMenuHelper;
+import org.eclipse.egit.ui.test.TestUtil;
+import org.eclipse.swtbot.eclipse.finder.waits.Conditions;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.ui.PlatformUI;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests for the Team->Gitflow->Feature Start/Finish actions
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public abstract class AbstractFeatureFinishHandlerTest extends AbstractGitflowHandlerTest {
+
+ protected void finishFeature() {
+ final SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
+ getProjectItem(projectExplorerTree, PROJ1).select();
+ final String[] menuPath = new String[] {
+ util.getPluginLocalizedValue("TeamMenu.label"),
+ util.getPluginLocalizedValue("TeamGitFlowMenu.name", false, Activator.getDefault().getBundle()),
+ util.getPluginLocalizedValue("TeamGitFlowFeatureFinish.name", false, Activator.getDefault().getBundle()) };
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ ContextMenuHelper.clickContextMenuSync(projectExplorerTree, menuPath);
+ }
+ });
+ selectOptions();
+ bot.button("OK").click();
+ preFinish();
+ bot.waitUntil(Conditions.waitForJobs(JobFamilies.GITFLOW_FAMILY, "Git flow jobs"));
+ }
+
+ protected void preFinish() {
+ // do nothing by default
+ }
+
+ abstract protected void selectOptions();
+
+ protected void init() throws CoreException {
+ new InitOperation(repository).execute(null);
+ }
+
+ @Override
+ protected void createFeature(String featureName) {
+ final SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
+ getProjectItem(projectExplorerTree, PROJ1).select();
+ final String[] menuPath = new String[] {
+ util.getPluginLocalizedValue("TeamMenu.label"),
+ util.getPluginLocalizedValue("TeamGitFlowMenu.name", false, Activator.getDefault().getBundle()),
+ util.getPluginLocalizedValue("TeamGitFlowFeatureStart.name", false, Activator.getDefault().getBundle()) };
+
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ ContextMenuHelper.clickContextMenuSync(projectExplorerTree, menuPath);
+ }
+ });
+
+ bot.waitUntil(shellIsActive(UIText.FeatureStartHandler_provideFeatureName));
+ bot.text().typeText(featureName);
+ bot.button("OK").click();
+ bot.waitUntil(Conditions.waitForJobs(JobFamilies.GITFLOW_FAMILY, "Git flow jobs"));
+ }
+
+ @Override
+ public void checkoutFeature(String featureName) {
+ final SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
+ getProjectItem(projectExplorerTree, PROJ1).select();
+ final String[] menuPath = new String[] {
+ util.getPluginLocalizedValue("TeamMenu.label"),
+ util.getPluginLocalizedValue("TeamGitFlowMenu.name", false, Activator.getDefault().getBundle()),
+ util.getPluginLocalizedValue("TeamGitFlowFeatureCheckout.name", false, Activator.getDefault().getBundle()) };
+
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ ContextMenuHelper.clickContextMenuSync(projectExplorerTree, menuPath);
+ }
+ });
+
+ bot.waitUntil(shellIsActive(UIText.FeatureCheckoutHandler_selectFeature));
+ bot.table().select(featureName);
+ bot.button("OK").click();
+ bot.waitUntil(Conditions.waitForJobs(JobFamilies.GITFLOW_FAMILY, "Git flow jobs"));
+ }
+
+ protected void checkoutBranch(String branchToCheckout) throws CoreException {
+ new BranchOperation(repository, branchToCheckout).execute(null);
+ }
+}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureFinishKeepBranchHandlerTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureFinishKeepBranchHandlerTest.java
index 947b64b58..790d7d537 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureFinishKeepBranchHandlerTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureFinishKeepBranchHandlerTest.java
@@ -8,24 +8,13 @@
*******************************************************************************/
package org.eclipse.egit.ui.gitflow;
-import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellIsActive;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.egit.core.op.BranchOperation;
import org.eclipse.egit.gitflow.GitFlowRepository;
-import org.eclipse.egit.gitflow.op.InitOperation;
-import org.eclipse.egit.gitflow.ui.Activator;
-import org.eclipse.egit.gitflow.ui.internal.JobFamilies;
import org.eclipse.egit.gitflow.ui.internal.UIText;
-import org.eclipse.egit.ui.test.ContextMenuHelper;
-import org.eclipse.egit.ui.test.TestUtil;
import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.swtbot.eclipse.finder.waits.Conditions;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.ui.PlatformUI;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -33,7 +22,8 @@ import org.junit.runner.RunWith;
* Tests for the Team->Gitflow->Feature Start/Finish actions
*/
@RunWith(SWTBotJunit4ClassRunner.class)
-public class FeatureFinishKeepBranchHandlerTest extends AbstractGitflowHandlerTest {
+public class FeatureFinishKeepBranchHandlerTest extends
+ AbstractFeatureFinishHandlerTest {
@Test
public void testFeatureFinishKeepBranch() throws Exception {
@@ -57,51 +47,8 @@ public class FeatureFinishKeepBranchHandlerTest extends AbstractGitflowHandlerTe
assertNotNull(findBranch(gfRepo.getConfig().getFeatureBranchName(FEATURE_NAME)));
}
- private void finishFeature() {
- final SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
- getProjectItem(projectExplorerTree, PROJ1).select();
- final String[] menuPath = new String[] {
- util.getPluginLocalizedValue("TeamMenu.label"),
- util.getPluginLocalizedValue("TeamGitFlowMenu.name", false, Activator.getDefault().getBundle()),
- util.getPluginLocalizedValue("TeamGitFlowFeatureFinish.name", false, Activator.getDefault().getBundle()) };
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- ContextMenuHelper.clickContextMenuSync(projectExplorerTree, menuPath);
- }
- });
- bot.checkBox(UIText.FinishFeatureDialog_keepBranch).click();
- bot.button("OK").click();
- bot.waitUntil(Conditions.waitForJobs(JobFamilies.GITFLOW_FAMILY, "Git flow jobs"));
- }
-
- private void init() throws CoreException {
- new InitOperation(repository).execute(null);
- }
-
@Override
- public void checkoutFeature(String featureName) {
- final SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
- getProjectItem(projectExplorerTree, PROJ1).select();
- final String[] menuPath = new String[] {
- util.getPluginLocalizedValue("TeamMenu.label"),
- util.getPluginLocalizedValue("TeamGitFlowMenu.name", false, Activator.getDefault().getBundle()),
- util.getPluginLocalizedValue("TeamGitFlowFeatureCheckout.name", false, Activator.getDefault().getBundle()) };
-
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- ContextMenuHelper.clickContextMenuSync(projectExplorerTree, menuPath);
- }
- });
-
- bot.waitUntil(shellIsActive(UIText.FeatureCheckoutHandler_selectFeature));
- bot.table().select(featureName);
- bot.button("OK").click();
- bot.waitUntil(Conditions.waitForJobs(JobFamilies.GITFLOW_FAMILY, "Git flow jobs"));
- }
-
- private void checkoutBranch(String branchToCheckout) throws CoreException {
- new BranchOperation(repository, branchToCheckout).execute(null);
+ protected void selectOptions() {
+ bot.checkBox(UIText.FinishFeatureDialog_keepBranch).click();
}
}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureFinishSquashHandlerTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureFinishSquashHandlerTest.java
index 0154d8271..01e2a138a 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureFinishSquashHandlerTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureFinishSquashHandlerTest.java
@@ -15,23 +15,13 @@ import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.Iterator;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.egit.core.op.BranchOperation;
import org.eclipse.egit.gitflow.GitFlowRepository;
-import org.eclipse.egit.gitflow.op.InitOperation;
-import org.eclipse.egit.gitflow.ui.Activator;
-import org.eclipse.egit.gitflow.ui.internal.JobFamilies;
import org.eclipse.egit.gitflow.ui.internal.UIText;
-import org.eclipse.egit.ui.test.ContextMenuHelper;
-import org.eclipse.egit.ui.test.TestUtil;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.NoHeadException;
import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.swtbot.eclipse.finder.waits.Conditions;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.ui.PlatformUI;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -39,7 +29,8 @@ import org.junit.runner.RunWith;
* Tests for the Team->Gitflow->Feature Finish action with squash option
*/
@RunWith(SWTBotJunit4ClassRunner.class)
-public class FeatureFinishSquashHandlerTest extends AbstractGitflowHandlerTest {
+public class FeatureFinishSquashHandlerTest extends
+ AbstractFeatureFinishHandlerTest {
private static final String SQUASHED_COMMENT_SUMMARY = "Hello World";
@@ -88,33 +79,16 @@ public class FeatureFinishSquashHandlerTest extends AbstractGitflowHandlerTest {
return count;
}
- private void finishFeature() {
- final SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
- getProjectItem(projectExplorerTree, PROJ1).select();
- final String[] menuPath = new String[] {
- util.getPluginLocalizedValue("TeamMenu.label"),
- util.getPluginLocalizedValue("TeamGitFlowMenu.name", false, Activator.getDefault().getBundle()),
- util.getPluginLocalizedValue("TeamGitFlowFeatureFinish.name", false, Activator.getDefault().getBundle()) };
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- ContextMenuHelper.clickContextMenuSync(projectExplorerTree, menuPath);
- }
- });
- bot.checkBox(UIText.FinishFeatureDialog_squashCheck).click();
- bot.button("OK").click();
+ @Override
+ protected void preFinish() {
int firstLine = 0;
bot.styledText().selectLine(firstLine);
bot.styledText().typeText(SQUASHED_COMMENT_SUMMARY);
bot.button("OK").click();
- bot.waitUntil(Conditions.waitForJobs(JobFamilies.GITFLOW_FAMILY, "Git flow jobs"));
}
- private void init() throws CoreException {
- new InitOperation(repository).execute(null);
- }
-
- private void checkoutBranch(String branchToCheckout) throws CoreException {
- new BranchOperation(repository, branchToCheckout).execute(null);
+ @Override
+ protected void selectOptions() {
+ bot.checkBox(UIText.FinishFeatureDialog_squashCheck).click();
}
}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureStartFinishHandlerTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureStartFinishHandlerTest.java
index 0e640c31b..4583be24e 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureStartFinishHandlerTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureStartFinishHandlerTest.java
@@ -8,24 +8,12 @@
*******************************************************************************/
package org.eclipse.egit.ui.gitflow;
-import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellIsActive;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.egit.core.op.BranchOperation;
import org.eclipse.egit.gitflow.GitFlowRepository;
-import org.eclipse.egit.gitflow.op.InitOperation;
-import org.eclipse.egit.gitflow.ui.Activator;
-import org.eclipse.egit.gitflow.ui.internal.JobFamilies;
-import org.eclipse.egit.gitflow.ui.internal.UIText;
-import org.eclipse.egit.ui.test.ContextMenuHelper;
-import org.eclipse.egit.ui.test.TestUtil;
import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.swtbot.eclipse.finder.waits.Conditions;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.ui.PlatformUI;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -33,7 +21,7 @@ import org.junit.runner.RunWith;
* Tests for the Team->Gitflow->Feature Start/Finish actions
*/
@RunWith(SWTBotJunit4ClassRunner.class)
-public class FeatureStartFinishHandlerTest extends AbstractGitflowHandlerTest {
+public class FeatureStartFinishHandlerTest extends AbstractFeatureFinishHandlerTest {
@Test
public void testFeatureStart() throws Exception {
@@ -57,72 +45,8 @@ public class FeatureStartFinishHandlerTest extends AbstractGitflowHandlerTest {
assertNull(findBranch(gfRepo.getConfig().getFeatureBranchName(FEATURE_NAME)));
}
- private void finishFeature() {
- final SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
- getProjectItem(projectExplorerTree, PROJ1).select();
- final String[] menuPath = new String[] {
- util.getPluginLocalizedValue("TeamMenu.label"),
- util.getPluginLocalizedValue("TeamGitFlowMenu.name", false, Activator.getDefault().getBundle()),
- util.getPluginLocalizedValue("TeamGitFlowFeatureFinish.name", false, Activator.getDefault().getBundle()) };
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- ContextMenuHelper.clickContextMenuSync(projectExplorerTree, menuPath);
- }
- });
- bot.button("OK").click();
- bot.waitUntil(Conditions.waitForJobs(JobFamilies.GITFLOW_FAMILY, "Git flow jobs"));
- }
-
- private void init() throws CoreException {
- new InitOperation(repository).execute(null);
- }
-
@Override
- protected void createFeature(String featureName) {
- final SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
- getProjectItem(projectExplorerTree, PROJ1).select();
- final String[] menuPath = new String[] {
- util.getPluginLocalizedValue("TeamMenu.label"),
- util.getPluginLocalizedValue("TeamGitFlowMenu.name", false, Activator.getDefault().getBundle()),
- util.getPluginLocalizedValue("TeamGitFlowFeatureStart.name", false, Activator.getDefault().getBundle()) };
-
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- ContextMenuHelper.clickContextMenuSync(projectExplorerTree, menuPath);
- }
- });
-
- bot.waitUntil(shellIsActive(UIText.FeatureStartHandler_provideFeatureName));
- bot.text().typeText(featureName);
- bot.button("OK").click();
- bot.waitUntil(Conditions.waitForJobs(JobFamilies.GITFLOW_FAMILY, "Git flow jobs"));
- }
-
- @Override
- public void checkoutFeature(String featureName) {
- final SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
- getProjectItem(projectExplorerTree, PROJ1).select();
- final String[] menuPath = new String[] {
- util.getPluginLocalizedValue("TeamMenu.label"),
- util.getPluginLocalizedValue("TeamGitFlowMenu.name", false, Activator.getDefault().getBundle()),
- util.getPluginLocalizedValue("TeamGitFlowFeatureCheckout.name", false, Activator.getDefault().getBundle()) };
-
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- ContextMenuHelper.clickContextMenuSync(projectExplorerTree, menuPath);
- }
- });
-
- bot.waitUntil(shellIsActive(UIText.FeatureCheckoutHandler_selectFeature));
- bot.table().select(featureName);
- bot.button("OK").click();
- bot.waitUntil(Conditions.waitForJobs(JobFamilies.GITFLOW_FAMILY, "Git flow jobs"));
- }
-
- private void checkoutBranch(String branchToCheckout) throws CoreException {
- new BranchOperation(repository, branchToCheckout).execute(null);
+ protected void selectOptions() {
+ // do nothing
}
}

Back to the top