I have a project that creates both a jni .so file and a java .jar file. All this is working as expected except JUnit test execution. I need the JUnit test to run after the native-maven-plugin creates the .so file. JUnit test will always fail when new JNI methods are added because they are running before the shared library has been created. Is the only option to build twice? Meaning build once skipping test then either execute tests separately or run build again to execute the test?
How to get JUnit tests to run after JNI .so creation with native-maven plugin
151 views Asked by musterjunk At
2
There are 2 answers
0
musterjunk
On
Ok, this was a project structure issue. I was trying to get tests that belonged to a different project to run after my JNI .so was built in my JNI project. What I needed to do was put the JNI integration tests I was creating in src/java/test in the JNI project, not another project and try to order them somehow.
jni -
|
src
|
java
|
test
not
other project-
|
src
|
java
|
test
of course maven ran the other project test after the other project was built. That is what it suppose to do. Even though the JNI project built a C .so file. The Java rule for testing still apply to the JNI project when it comes to running java tests.
Related Questions in MAVEN
- Accessing Secret Variables in Classic Pipelines through Java app in Azure DevOps
- JavaFX build generating a blank gui with primary view and secondary view buttons
- Maven (Java) does not build dependencies into a compiled file
- java.lang.ClassNotFoundException: javax.servlet.jsp.tagext.TagLibraryValidator in Spring-boot jsp application
- I am trying to use h2 in-memory db from my spring boot application, my spring boot version is 3.1.10, but its not connecting to h2 properly
- BeanCreationException when deploying Spring Boot app
- How to run Parallel tests by groups using Maven and TestNG?
- Get control flow information with JaCoCo
- Failed to instantiate [com.docusign.esign.client.ApiClient]
- Gradle - Groovy vs Gradle - Kotlin vs Maven for Java Spring Boot web application project on IntelliJ
- Intelij ultimate and spring boot giving me errors
- Using Eclipse Maven project, import new version of a class from a jar file created from another Maven project
- Messing up with conflict between spring jcl and commons-logging.jar
- Run java program
- How to add a Maven project to an Ubuntu image in Docker
Related Questions in JUNIT
- Embedded Kafka Failed to Start After Spring Starter Parent Version 3.1.10
- Springframework test: Async not started
- Problems running both JUnit tests and Selenium/Cucumber tests at the same time
- Writing test methods with shared expensive set-up
- Mocking Stream or Reader in Java Junit
- Junit test: NoSuchElementException, Mock getConnection
- Get program traces with JaCoCo
- Junit test with Mockito: Error ExceptionInInitializerError
- How to Mock HttpResponse
- How to mock dependency in service class from Junit
- classNotPreparedForTest exception, using JUNIT5, MOCKITO and POWERMOCKITO
- Ant Junit ForkMode with Suites
- I import JUnit to Eclipse and still does not work
- Mock DriverManager.getconnection method for junit/mockito unit tests
- throwing a StaleElementReferenceException during dictionary iteration in a for loop
Related Questions in BUILD
- Build issue in my STM32-NUCLEO project using the Eclipse IDE
- Module not found when building flutter app for IOS
- Why am I getting this error ? error CS0103: The name 'EnhancedStackTrace' does not exist in the current context
- Gradle 8.7 cannot find installed JDK 22 in IntelliJ
- Build LLVM, Clang and Libfuzzer
- when I open a ktor project, error Cannot invoke "java.nio.file.Path.toString()" because the return value of "java.nio.file.Path.getFileName()" is null
- Cannot make Django run the frontend from Vite's build ("was blocked because of a disallowed MIME type (“text/html”)")
- Distorted CSS after Build process
- how to build nextjs app unable to build and deploy
- How to build custom mediapipe python model i.e. adding flow_limiter_calculator to face_landmark_front_cpu.binarypb
- Assets not showing after build process in Vite and React
- "Config.guess failed to determine the host type" when trying build binutils-2.7 with Cygwin
- The assembled Python application does not launch
- Why rebuild module does not recompile dependency module, but build module does in IntelliJ Idea?
- Gitlab pipeline stuck with nx cloud issue
Related Questions in NATIVE-MAVEN-PLUGIN
- native-maven-plugin: combine reachability metadata with custom reflection config and predefined classes
- Increase heap memory when building native image with Spring native
- Created Exe of Spring boot application Using GraalVM, It will immediately terminate after start
- How to load custom property file located inside a folder in resources in graalvm native image?
- Run native tests without JVM tests in Spring Boot 3
- custom runtime issue with native-maven-plugin having metadataRepository enabled
- Build c program with Maven?
- How to get JUnit tests to run after JNI .so creation with native-maven plugin
- How to Avoid needing to set LD_LIBRARY_PATH ld : collect2 fails
- native-maven-plugin fails on "a" packaging type
- Java JNI Maven native-maven-plugin - how to set shared library final name
- native-maven-plugin jni osx pom
- native-maven-plugin error with msvc compiler "The command line is too long."
- No basedir set from native-maven-plugin
- Force relative debug symbol path (maven-native-plugin)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
i guess you are using the native:link goal from the native-maven-plugin?
if you look at the documentation of the goal you see that it is bound by default to the lifecycle phase package.
junit tests (run by maven-surefire-plugin) are run by default in the lifecycle phase test (https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html).
in the maven lifecycle reference you can see that the test phase is before the package phase. this explains why your tests fail after you have made changes. Tests are run first, .so file is generated afterwards.
You can use the maven-failsafe-plugin to run tests after package phase.
add the plugin to your build and name all tests that should be run after package to MySpecificFeatureIT (the suffix IT stands for Integration Test). Tests named MyFeatureTest will still be run in test phase.
see the plugin documentation for more details