Permalink
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...
1 parent 035ca88 commit bca02886d852dc388cebda41ccfc1e3837a74fa0 @schauder committed Jan 1, 2014
View
@@ -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))
}
@@ -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()
@@ -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
@@ -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())));
}
}
@@ -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

0 comments on commit bca0288

Please sign in to comment.