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

Configure template for Java unit tests #14

Open
mjansen4857 opened this issue Nov 18, 2022 · 2 comments
Open

Configure template for Java unit tests #14

mjansen4857 opened this issue Nov 18, 2022 · 2 comments

Comments

@mjansen4857
Copy link
Contributor

The template already includes configuration for running unit tests on native code, but does not include configuration for any Java tests. I have added my own configuration as is documented here for robot projects:

dependencies {
    ...

    testImplementation 'junit:junit:4.12'
}

...

test {
    useJUnit()
}

This works fine unless a test requires use of the HAL i.e. HAL.initialize(500, 0). This will throw an exception:

java.io.IOException: wpiHaljni could not be loaded from path or an embedded resource.
	attempted to load for platform /windows/x86-64/

I have tried this on a fresh copy of the template on a couple different computers that are able to run these tests just fine in a robot project, so I believe there is some extra configuration that the GradleRIO plugin would normally take care of and not an issue with my system.

@ThadHouse
Copy link
Member

There is extra configuration gradlerio does to enable testing. It’s a bit more complex to add here, the solution is to create an executable, and then use some gradle magic to make the unit tests depend on that executable, and use that executable to find the native libraries.

@mjansen4857
Copy link
Contributor Author

That sounds far beyond my gradle ability. Does it make sense to add this change to the template?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants