Skip to content

Commit

Permalink
Update JUnit Label names, fixes #2088
Browse files Browse the repository at this point in the history
   - add some check for other tests

Signed-off-by: Ondrej Dockal <odockal@redhat.com>
  • Loading branch information
odockal committed Aug 26, 2020
1 parent 47496c3 commit 7b70b98
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
*******************************************************************************/
package org.eclipse.reddeer.eclipse.jdt.junit.ui;

import org.eclipse.reddeer.common.matcher.RegexMatcher;
import org.eclipse.reddeer.common.wait.WaitWhile;
import org.eclipse.reddeer.core.matcher.WithLabelMatcher;
import org.eclipse.reddeer.swt.condition.ShellIsAvailable;
import org.eclipse.reddeer.swt.impl.button.OkButton;
import org.eclipse.reddeer.swt.impl.button.PushButton;
Expand Down Expand Up @@ -44,7 +46,7 @@ public TestRunnerViewPart() {
*/
public String getRunStatus() {
activate();
return new LabeledText(cTabItem, "Runs: ").getText().trim();
return new LabeledText(cTabItem, new WithLabelMatcher(new RegexMatcher("Runs:.*"))).getText().trim();
}

/**
Expand All @@ -54,7 +56,7 @@ public String getRunStatus() {
*/
public int getNumberOfErrors() {
activate();
String errorStatus = new LabeledText(cTabItem, "Errors: ").getText().trim();
String errorStatus = new LabeledText(cTabItem, new WithLabelMatcher(new RegexMatcher("Errors:.*"))).getText().trim();
return Integer.valueOf(errorStatus);
}

Expand All @@ -65,7 +67,7 @@ public int getNumberOfErrors() {
*/
public int getNumberOfFailures() {
activate();
String errorStatus = new LabeledText(cTabItem, "Failures: ").getText().trim();
String errorStatus = new LabeledText(cTabItem, new WithLabelMatcher(new RegexMatcher("Failures:.*"))).getText().trim();
return Integer.valueOf(errorStatus);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.eclipse.reddeer.swt.impl.shell.DefaultShell;
import org.eclipse.reddeer.swt.impl.table.DefaultTable;
import org.eclipse.reddeer.swt.impl.text.DefaultText;
import org.eclipse.reddeer.workbench.core.condition.JobIsRunning;

/**
* Interface that brings default behavior for Class/Interface/Enum wizards that can 'implement'.
Expand All @@ -42,6 +43,7 @@ public default void addExtendedInterface(String interfaceName) {
new PushButton("Add...").click();
new DefaultShell(new WithTextMatcher(new RegexMatcher("[Extended|Implemented].*Interfaces Selection")));
new DefaultText(0).setText(interfaceName);
new WaitUntil(new JobIsRunning(), TimePeriod.MEDIUM, false);
new WaitUntil(new TableHasRows(new DefaultTable(0)), TimePeriod.DEFAULT, false);

switch (new DefaultTable(0).getItems().size()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
package org.eclipse.reddeer.swt.impl.text;

import org.eclipse.reddeer.swt.api.Text;
import org.hamcrest.Matcher;
import org.eclipse.reddeer.core.matcher.WithLabelMatcher;
import org.eclipse.reddeer.core.reference.ReferencedComposite;

Expand Down Expand Up @@ -40,4 +41,14 @@ public LabeledText(String label) {
public LabeledText(ReferencedComposite referencedComposite, String label) {
super(referencedComposite, 0, new WithLabelMatcher(label));
}

/**
* Default text with a label matcher inside given composite.
*
* @param referencedComposite the referenced composite
* @param matcher matcher for the label matching
*/
public LabeledText(ReferencedComposite referencedComposite, Matcher<?>... matcher) {
super(referencedComposite, 0, matcher);
}
}
4 changes: 3 additions & 1 deletion tests/org.eclipse.reddeer.eclipse.test/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ Require-Bundle: org.eclipse.reddeer.go;bundle-version="[2.2.0,3.1.1)",
org.eclipse.debug.core,
org.eclipse.ui.views.log,
org.eclipse.ui.browser,
org.eclipse.ui,
org.eclipse.jst.ejb.ui,
org.eclipse.datatools.connectivity.dbdefinition.genericJDBC,
org.eclipse.datatools.sqltools.sqlscrapbook;bundle-version="1.0.2",
org.eclipse.datatools.sqltools.result.ui;bundle-version="1.1.3",
org.eclipse.jdt.ui,
org.eclipse.jdt.junit4.runtime
org.eclipse.jdt.junit4.runtime,
org.eclipse.jdt.junit
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: org.hamcrest.core
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
import static org.junit.Assert.assertTrue;

import org.eclipse.reddeer.common.exception.WaitTimeoutExpiredException;
import org.eclipse.reddeer.common.wait.TimePeriod;
import org.eclipse.reddeer.common.wait.WaitUntil;
import org.eclipse.reddeer.common.wait.WaitWhile;
import org.eclipse.reddeer.eclipse.jdt.ui.wizards.JavaProjectWizard;
import org.eclipse.reddeer.eclipse.jdt.ui.wizards.NewJavaProjectWizardPageOne;
import org.eclipse.reddeer.eclipse.jdt.ui.wizards.NewJavaProjectWizardPageTwo;
Expand All @@ -22,6 +25,7 @@
import org.eclipse.reddeer.requirements.cleanworkspace.CleanWorkspaceRequirement.CleanWorkspace;
import org.eclipse.reddeer.swt.impl.button.RadioButton;
import org.eclipse.reddeer.swt.impl.combo.DefaultCombo;
import org.eclipse.reddeer.workbench.core.condition.JobIsRunning;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
Expand Down Expand Up @@ -108,6 +112,8 @@ public void testJavaProjectWizardCreateInfoModule() {
dialog.next();

NewJavaProjectWizardPageTwo pageTwo = new NewJavaProjectWizardPageTwo(dialog);
new WaitUntil(new JobIsRunning(), TimePeriod.MEDIUM, false);
new WaitWhile(new JobIsRunning(), TimePeriod.MEDIUM, false);
pageTwo.createModuleInfoFile(true);

dialog.finish(true, JAVA_MODULE_NAME);
Expand Down

0 comments on commit 7b70b98

Please sign in to comment.