3D-e-Chem / knime-testflow

Test Knime workflows from a Junit test.
GNU General Public License v3.0
2 stars 1 forks source link

TestFlowRunner throws SWTException: Invalid thread access #9

Open miguelalba opened 4 years ago

miguelalba commented 4 years ago

Hi!

I am sorry if this issue has already been reported. I looked in the closed issues and could not find it. I am following the example from the readme.

    @Rule
    public ErrorCollector collector = new ErrorCollector();

    private static TestFlowRunner runner;

    @Before
    public void setUp() {
        TestrunConfiguration runConfiguration = new TestrunConfiguration();
        runConfiguration.setLoadSaveLoad(false);
        runner = new TestFlowRunner(collector, runConfiguration);
    }

In my test method I have

runner.runTestWorkflow(new File("workflows/InitializeParentsAnimals"));

This is a simple workflow with only three nodes but the TestFlowRunner does not execute, it fails at the beginning of the runTestWorkflow method: https://github.com/3D-e-Chem/knime-testflow/blob/34348fc2c41b28632216e945cefd93b538bc32f2/plugin/src/java/nl/esciencecenter/e3dchem/knime/testing/TestFlowRunner.java#L80

The full trace is:


-------------------------------------------------------------------------------
Test set: de.bund.bfr.knime.fsklab.workflows.tests.WorkflowsTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.603 sec <<< FAILURE! - in de.bund.bfr.knime.fsklab.workflows.tests.WorkflowsTest
testChickenModels(de.bund.bfr.knime.fsklab.workflows.tests.WorkflowsTest)  Time elapsed: 2.514 sec  <<< ERROR!
org.eclipse.swt.SWTException: Invalid thread access
    at org.eclipse.swt.SWT.error(SWT.java:4533)
    at org.eclipse.swt.SWT.error(SWT.java:4448)
    at org.eclipse.swt.SWT.error(SWT.java:4419)
    at org.eclipse.swt.widgets.Display.error(Display.java:1090)
    at org.eclipse.swt.widgets.Display.createDisplay(Display.java:840)
    at org.eclipse.swt.widgets.Display.create(Display.java:823)
    at org.eclipse.swt.graphics.Device.<init>(Device.java:129)
    at org.eclipse.swt.widgets.Display.<init>(Display.java:722)
    at org.eclipse.swt.widgets.Display.<init>(Display.java:713)
    at org.eclipse.swt.widgets.Display.getDefault(Display.java:1420)
    at org.knime.workbench.core.KNIMECorePlugin.createImageRegistry(KNIMECorePlugin.java:501)
    at org.eclipse.ui.plugin.AbstractUIPlugin.getImageRegistry(AbstractUIPlugin.java:250)
    at org.knime.workbench.core.util.ImageRepository.getImage(ImageRepository.java:410)
    at org.knime.workbench.core.util.ImageRepository.getImage(ImageRepository.java:376)
    at nl.esciencecenter.e3dchem.knime.testing.TestFlowRunner.runTestWorkflow(TestFlowRunner.java:80)
    at de.bund.bfr.knime.fsklab.workflows.tests.WorkflowsTest.testChickenModels(WorkflowsTest.java:53)```
sverhoeven commented 4 years ago

Are you on MacOSX?

Some solutions might be in https://github.com/3D-e-Chem/knime-testflow/issues/3

miguelalba commented 4 years ago

Yes. So I get that I would need to run it with this profile?

<profiles>
    <profile>
        <id>macosx</id>
            <activation>
            <os>
                <name>mac os x</name>
                <family>mac</family>
            </os>
        </activation>
        <properties>
            <tycho.test.jvmArgs>-XstartOnFirstThread</tycho.test.jvmArgs>
            <custom.UIThread>false</custom.UIThread>
        </properties>
        <build>
    </build>
</profile>
sverhoeven commented 4 years ago

Yep, for example in https://github.com/3D-e-Chem/knime-silicos-it/blob/master/tests/pom.xml#L138-L153 it is used and the workflow tests work on Travis CI