Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Executing the HamcrestWrapper in a integration test

- need to add a hamcrest dependency for main code
- switched the HamcrestWrapper from wrapping a Matcher to wrapping a BeMatcher
- interestingly I had to declare an explicite return type to violationFree to make it work.
  • Loading branch information...
commit bca02886d852dc388cebda41ccfc1e3837a74fa0 1 parent 035ca88
@schauder authored
View
3  build.gradle
@@ -107,7 +107,8 @@ dependencies {
testCompile 'junit:junit:4.11'
compile 'org.scalatest:scalatest_2.10:2.0'
-
+ compile 'org.hamcrest:hamcrest-all:1.3'
+
//javafx
compile files(getJavaFXPath(javafxLib))
}
View
2  src/main/scala/de/schauderhaft/degraph/check/Check.scala
@@ -44,7 +44,7 @@ object Check {
* a matcher for Configurations testing if the classes specified in the configuration
* adhere to the dependency constraints configured in the configuration.
*/
- val violationFree = new BeMatcher[ConstraintBuilder] {
+ val violationFree: BeMatcher[ConstraintBuilder] = new BeMatcher[ConstraintBuilder] {
def apply(constraintBuilder: ConstraintBuilder) = {
val conf = constraintBuilder.configuration
val g = conf.createGraph()
View
2  src/main/scala/de/schauderhaft/degraph/hamcrest/HamcrestWrapper.scala
@@ -1,6 +1,6 @@
package de.schauderhaft.degraph.hamcrest
-import org.scalatest.matchers.{ Matcher => SMatcher }
+import org.scalatest.matchers.{ BeMatcher => SMatcher }
import org.hamcrest.Matcher
import org.hamcrest.TypeSafeMatcher
import org.hamcrest.Description
View
6 src/test/java/de/schauderhaft/degraph/check/JavaCheckApiTest.java
@@ -2,8 +2,12 @@
import de.schauderhaft.degraph.configuration.NamedPattern;
import de.schauderhaft.degraph.check.Check;
+import de.schauderhaft.degraph.hamcrest.HamcrestWrapper;
import org.junit.Test;
+import org.scalatest.Matchers;
+
+import scala.annotation.meta.beanGetter;
import static org.hamcrest.core.Is.*;
import static org.junit.Assert.assertThat;
@@ -56,6 +60,6 @@ public void degraphHonoursItsConstraintsJavaStyle() {
new NamedPattern("internal",
"de.schauderhaft.**"),
new NamedPattern("external", "**")),
- is(Check.violationFree()));
+ is(new HamcrestWrapper<ConstraintBuilder>(Check.violationFree())));
}
}
View
2  src/test/scala/de/schauderhaft/degraph/hamcrest/HamcrestWrapperTest.scala
@@ -4,7 +4,7 @@ import org.scalatest.Matchers._
import org.junit.runner.RunWith
import org.scalatest.FunSuite
import org.scalatest.junit.JUnitRunner
-import org.scalatest.matchers.{ Matcher => SMatcher }
+import org.scalatest.matchers.{ BeMatcher => SMatcher }
import org.hamcrest.{ Matcher => HMatcher }
import org.scalatest.matchers.MatchResult
import org.scalatest.prop.PropertyChecks
Please sign in to comment.
Something went wrong with that request. Please try again.