Skip to content

Commit

Permalink
Avoid Hamcrest as it breaks native tests
Browse files Browse the repository at this point in the history
  • Loading branch information
agarciadom committed May 22, 2024
1 parent fcdcb0b commit a6f79cf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ dependencies {
implementation("io.micronaut.serde:micronaut-serde-jackson")
implementation("org.eclipse.emfatic:org.eclipse.emfatic.core:1.1.0")
implementation("org.eclipse.platform:org.eclipse.core.resources:3.13.700")
testImplementation('org.hamcrest:hamcrest:2.2')
runtimeOnly("ch.qos.logback:logback-classic")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
import io.micronaut.configuration.picocli.PicocliRunner;
import io.micronaut.context.ApplicationContext;
import io.micronaut.context.env.Environment;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.fail;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
Expand All @@ -29,12 +28,17 @@ public void testStandaloneMetamodel() throws Exception {
try (ApplicationContext ctx = ApplicationContext.run(Environment.CLI, Environment.TEST)) {
String[] args = new String[] { "src/test/resources/OO.ecore" };
PicocliRunner.run(Ecore2EmfaticCommand.class, ctx, args);
assertThat("Should see a PackageableElement in the output",
baos.toString(), containsString("PackageableElement"));
assertContains("Should see a PackageableElement in the output", baos.toString(), "PackageableElement");
}
}

@Test
private void assertContains(String reason, String text, String substring) {
if (!text.contains(substring)) {
fail(String.format("%s, but did not contain '%s':\n%s", reason, substring, text));
}
}

@Test
public void testMetamodelWithPlatformImport() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
System.setOut(new PrintStream(baos));
Expand All @@ -46,8 +50,8 @@ public void testMetamodelWithPlatformImport() throws Exception {
"src/test/resources/platformImport/example2/ColoredTree.ecore"
};
PicocliRunner.run(Ecore2EmfaticCommand.class, ctx, args);
assertThat("Should see 'extends Trees.Tree' in the output",
baos.toString(), containsString("extends Trees.Tree"));
assertContains("Should see 'extends Trees.Tree' in the output",
baos.toString(), "extends Trees.Tree");
}
}
}

0 comments on commit a6f79cf

Please sign in to comment.