Skip to content

Commit

Permalink
issue #467: moved ErrorCause and ErrorType to their own file
Browse files Browse the repository at this point in the history
  • Loading branch information
bhecquet committed Nov 24, 2021
1 parent e75488a commit 34e376a
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 60 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.seleniumtests.core.testanalysis;

public class ErrorCause {

private ErrorType type;
private String description;

public ErrorCause(ErrorType type, String description) {
this.type = type;
this.description = description;
}

public ErrorType getType() {
return type;
}

public String getDescription() {
return description;
}

@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}

if (obj instanceof ErrorCause && this == obj) {
return true;
}

ErrorCause cause = (ErrorCause)obj;
return cause.description != null && cause.description.equals(description) && cause.type == type;

}

@Override
public int hashCode() {
if (description != null) {
return description.hashCode();
} else {
return 0;
}

}


}
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ public class ErrorCauseFinder {
* TESTS:
* - si le ImageFieldDetector ne s'initialise pas, il ne faut pas planter
* - on n'a pas le stepResultId => on doit renvoyer null
* - Label.match()
* - Field.match()
* - StepReferenceComparator
*/

private static final String[] ERROR_WORDS = new String[] {"error", "erreur", "problem", "problème"};
Expand All @@ -55,61 +52,8 @@ public class ErrorCauseFinder {

private ITestResult testResult;

public enum ErrorType {
ERROR_MESSAGE, // error message displayed
ERROR_IN_FIELD, // some field shows an error (it's coloured in red)
APPLICATION_CHANGED, // compared to the page we expect, the page we are on is slightly different
SELENIUM_ERROR // we are not on the right page to perform our actions, it may be due to a problem when clicking during previous step
}

public class ErrorCause {

private ErrorType type;
private String description;

public ErrorCause(ErrorType type, String description) {
this.type = type;
this.description = description;
}

public ErrorType getType() {
return type;
}

public String getDescription() {
return description;
}

@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}

if (obj instanceof ErrorCause && this == obj) {
return true;
}

ErrorCause cause = (ErrorCause)obj;
if (cause.description != null && cause.description.equals(description) && cause.type == type) {
return true;
} else {
return false;
}
}

@Override
public int hashCode() {
if (description != null) {
return description.hashCode();
} else {
return 0;
}

}


}

public ErrorCauseFinder(ITestResult testResult) {
this.testResult = testResult;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.seleniumtests.core.testanalysis;


public enum ErrorType {
ERROR_MESSAGE, // error message displayed
ERROR_IN_FIELD, // some field shows an error (it's coloured in red)
APPLICATION_CHANGED, // compared to the page we expect, the page we are on is slightly different
SELENIUM_ERROR // we are not on the right page to perform our actions, it may be due to a problem when clicking during previous step
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@
import com.seleniumtests.core.SeleniumTestsContextManager;
import com.seleniumtests.core.TestVariable;
import com.seleniumtests.core.runner.CucumberScenarioWrapper;
import com.seleniumtests.core.testanalysis.ErrorCauseFinder.ErrorCause;
import com.seleniumtests.core.testanalysis.ErrorCause;
import com.seleniumtests.customexception.ScenarioException;
import com.seleniumtests.customexception.SeleniumRobotServerException;
import com.seleniumtests.driver.screenshots.SnapshotComparisonBehaviour;
import com.seleniumtests.reporter.info.Info;
import com.seleniumtests.reporter.info.StringInfo;
import com.seleniumtests.reporter.logger.Snapshot;
import com.seleniumtests.reporter.logger.TestStep;
import com.seleniumtests.reporter.reporters.CommonReporter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,4 @@ public void testCompareNoFieldNoLabel() throws Exception {
Assert.assertEquals(comparator.compare(), 100);
}


// avec une partie du matching seulement
}

0 comments on commit 34e376a

Please sign in to comment.