GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - mpeddada1/junit-experiment: Experiment with Junit annotations and tags for native image testing

BranchesTags
Open more actions menu

Latest commit

 

History

13 Commits
13 Commits

Folders and files

NameName
Last commit message
Last commit date
child-project-2
child-project-2
 
 
child-project-3
child-project-3
 
 
child-project
child-project
 
 
test-results-native/test
test-results-native/test
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
pom.xml
pom.xml
 
 

Repository files navigation

junit-experiment

child-project-2 : Testing with FileSystemProvider

To run the application, we call mvn test -P native. To reproduce the issue, delete the contents of the main/resources/META-INF/native-image/native-image.properties file.

We will see the following error at image build time:

Error: Classes that should be initialized at run time got initialized during image building:
 com.example.MySampleFileSystemProvider was unintentionally initialized at build time. To see why com.example.MySampleFileSystemProvider got initialized use --trace-class-initialization=com.example.MySampleFileSystemProvider

Now, if we add --initialize-at-run-time=com.example.MySampleFileSystemProvider, we will see the following error:

Error: The class com.example.MySampleFileSystemProvider has already been initialized (from file:///usr/local/google/home/mpeddada/IdeaProjects/native-image-experiments/junit-experiment/child-project-2/target/classes/META-INF/native-image/native-image.properties with 'com.example.MySampleFileSystemProvider'); it is too late to register com.example.MySampleFileSystemProvider for build-time initialization. To see why com.example.MySampleFileSystemProvider got initialized use --trace-class-initialization=com.example.MySampleFileSystemProvider

Including --initialize-build-time=com.example.MySampleFileSystemProvider results in a successful build.

[UPDATE] When MyOptions is instantiated in MySampleFileSystemProvider with private static MyOptions storageOptions = new MyOptions();, we will notice that the build breaks because it is unexpectedly initialized at build time.

child-project-3 : Testing with Category tag

Experiment with Junit annotations and tags for native image testing.

To run the application, we call mvn test -P native.

When the Category tag is used, it results in the following error:

org.junit.platform.engine.TestTag was unintentionally initialized at build time. org.junit.platform.engine.TestTag caused initialization of this class with the following trace: 
	at org.junit.platform.engine.TestTag.<clinit>(TestTag.java:54)
  at org.junit.platform.engine.TestTag.<clinit>(TestTag.java:54)
	at org.junit.vintage.engine.descriptor.VintageTestDescriptor$$Lambda$656/0x00000007c23d8440.apply(Unknown Source)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
  ...
at org.junit.platform.engine.TestDescriptor.lambda$accept$0(TestDescriptor.java:251)
	at org.junit.platform.engine.TestDescriptor$$Lambda$639/0x00000007c23d4040.accept(Unknown Source)
	at java.lang.Iterable.forEach(Iterable.java:75)
	at org.junit.platform.engine.TestDescriptor.accept(TestDescriptor.java:251)
	at org.junit.platform.launcher.TestPlan.lambda$from$1(TestPlan.java:95)
	at org.junit.platform.launcher.TestPlan$$Lambda$649/0x00000007c23d6840.accept(Unknown Source)
	at java.util.LinkedHashMap$LinkedValues.forEach(LinkedHashMap.java:608)
	at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1085)
	at org.junit.platform.launcher.TestPlan.from(TestPlan.java:95)
	at org.junit.platform.launcher.core.InternalTestPlan.from(InternalTestPlan.java:32)
	at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:78)
	at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.discover(DefaultLauncherSession.java:81)
	at org.junit.platform.launcher.core.SessionPerRequestLauncher.discover(SessionPerRequestLauncher.java:46)
	at org.graalvm.junit.platform.JUnitPlatformFeature.discoverTestsAndRegisterTestClassesForReflection(JUnitPlatformFeature.java:135)

The failure seems to happening when VintageTestDescriptor calls the TestTag object which is not recognized by the native image builder.

This error is resolved when the --initialize-at-build-time=org.junit.platform.engine.TestTag option is used.

About

Experiment with Junit annotations and tags for native image testing

Resources

Readme
Activity

Stars

0 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.