Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip org.junit.AssumptionViolatedException correctly without wrapping with Embulk's Exceptions. #671

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dmikurube
Copy link
Member

Plugin testing code cannot skip tests with org.junit.Assume since AssumptionViolatedException is even wrapped with Embulk's internal Exceptions. JUnit cannot recognize AssumptionViolatedException to skip correctly because of this wrapping.

@muga Wdyt?

@muga
Copy link
Contributor

muga commented Jun 13, 2017

@dmikurube This is good idea. How about the following test? Is it out of scope of this PR? It seems that the test's still not ignored.

My test:

import org.embulk.EmbulkTestRuntime;
import org.junit.Assume;
import org.junit.Rule;
import org.junit.Test;

public class SimpleTest
{
    @Rule
    public EmbulkTestRuntime runtime = new EmbulkTestRuntime();

    @Test
    public void test()
            throws Exception
    {
        Assume.assumeTrue(false);
        System.out.println("Not call here");
    }
}

The stacktrace:

java.util.concurrent.ExecutionException: org.embulk.EmbulkTestRuntime$RuntimeExecutionException: org.junit.AssumptionViolatedException: got: <false>, expected: is <true>

	at org.embulk.spi.Exec.doWith(Exec.java:27)
	at org.embulk.EmbulkTestRuntime$1.evaluate(EmbulkTestRuntime.java:87)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: org.embulk.EmbulkTestRuntime$RuntimeExecutionException: org.junit.AssumptionViolatedException: got: <false>, expected: is <true>
	at org.embulk.EmbulkTestRuntime$1$1.run(EmbulkTestRuntime.java:93)
	at org.embulk.EmbulkTestRuntime$1$1.run(EmbulkTestRuntime.java:87)
	at org.embulk.spi.Exec.doWith(Exec.java:25)
	... 20 more
Caused by: org.junit.AssumptionViolatedException: got: <false>, expected: is <true>
	at org.junit.Assume.assumeThat(Assume.java:95)
	at org.junit.Assume.assumeTrue(Assume.java:41)
	at SimpleTest.test(SimpleTest.java:15)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
	at org.embulk.EmbulkTestRuntime$1$1.run(EmbulkTestRuntime.java:91)
	... 22 more

@muga
Copy link
Contributor

muga commented Jun 13, 2017

How about EmbulkTestRuntime might throw AssumptionViolatedException if it could detect AssumptionViolatedException that is included in the caught exception. It seems that My IntelliJ treats AssumptionViolatedException in the same way as @Ignored unit test.

@dmikurube dmikurube added the enhancement New feature or request label Jun 13, 2017
@dmikurube dmikurube added this to the v0.9 milestone Nov 21, 2017
@dmikurube dmikurube removed this from the v0.9.0 milestone Jan 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

2 participants