Minimal plugin test failing with "JNA library not available"

Answered

I am trying to create a plugin test that uses creates a IdeaProjectTestFixture using IdeaTestFixtureFactory, but trying to call fixture.setUp() from my test’s setUp() triggers java.lang.AssertionError: JNA library. The plugin targets IDEA 203.7717.56, and I’m trying to run the tests on Apple Silicon (M1 Pro).

Here is the entire test file:

package com.example.somepackage

import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

@RunWith(JUnit4::class)
class TempFileTest {
private val fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory()
private val fixtureBuilder = fixtureFactory.createFixtureBuilder("MyProject")
private val fixture = fixtureBuilder.fixture

@Before
fun setUp() {
fixture.setUp()
}

@After
fun tearDown() {
fixture.tearDown()
}

@Test
fun nothing() {
assertEquals(4, 2 + 2)
}
}

Since the stack trace is very large, I’ve uploaded it to:

Upload id: 2022_11_06_mvtrN3SDiCrwcTquRMCDuu (file: jna_stack_trace_2.txt)

Please let me know if you need any more information. Thanks!

4 comments
Comment actions Permalink

Please try building against 

Version: 2020.3.4 (Release notes)

Build: 203.8084.24

instead.

Are you using the latest Gradle IntelliJ Plugin (1.9.0 currently)?

0
Comment actions Permalink

Thanks for getting back to me! I tried changing the target IDEA version to 203.8084.24, and I get the same issue: java.lang.AssertionError: JNA library is not available

As for the Gradle plugin, I assume you mean this section of build.gradle:

plugins {
...
id 'org.jetbrains.intellij' version '1.10.0'
}

Do you think this might be related to me testing on a Mac with M1 Pro? (Unfortunately, I don’t have an Intel Mac to test on.)

0
Comment actions Permalink

Could you please try building against newer platform version, e.g. 2022.2?

0
Comment actions Permalink

I am having a similar issue: https://intellij-support.jetbrains.com/hc/en-us/community/posts/8588167047954-Unit-tests-fail-on-Apple-Silicon-with-Gradle-test-task-but-pass-with-JUnit-test-runner

Tests pass as expected on older Intel Macs, but fail on a new M1 MacBook. Also, the tests only fail when run as a Gradle task. Try running the tests using a JUnit run configuration in IntelliJ.

 

0

Please sign in to leave a comment.