question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow certain features and extensions to be turned off while testing

See original GitHub issue

I want to add some unit tests to my Quarkus maven project. I’m working on a multi-module project structured as:

  • parent
    • persistence (2 profiles [postgres, oracle])
    • business (depends on persistence module)
    • resource (depends on business module)
    • deploy-rest (with quarkus maven plugin)
    • deploy-lambda (with quarkus maven plugin)

The test is very simple (empty implementation) and is located in the business module.

@QuarkusTest
class CARootCreateControllerImplTest {

    @Test
    void handleRequest() {

    }
}

When I try to execute my test, quarkus raises an error because agroal (from persistence dependency) needs the database configuration. First question: how can I run only unit tests (not integration) that don’t use the database but only mocks?

However, I have tried to solve the problem by adding a test/resource/application.properties fake configuration and agroal this time found it, raising another error. This second error is that the Postgres-JDBC driver is not found. This is correct because only the persistence module knows the dependency (using the correct profile). Second question: if it is not possible to avoid the first question, how can I avoid placing additional dependencies on the module that runs the test?

Expected behavior

I want to run a single unit test (not integration) without database configuration/installation in Quarkus.

Actual behavior

If a single Entity is defined, agroal extension need a configuration to a running database

How to Reproduce?

Add a test like

@QuarkusTest
class CARootCreateControllerImplTest {

    @Test
    void handleRequest() {

    }
}

in a maven module with the agroal extension enabled and no application.properties configured.

Output of uname -a or ver

Linux 2019-150507 5.10.60.1-microsoft-standard-WSL2

Output of java -version

OpenJDK 64-Bit Server VM (build 11.0.10+9-Ubuntu-0ubuntu1.20.04, mixed mode)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.2.3-Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.6.3

Additional information

No response

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
voronovmaksimcommented, Apr 26, 2022

Thanks a lot @geoand.

My use case is like use case of issue specified by you. I run unit test with annotation @QuarkusTest and the unit test is failed because of hibernate Exception, but my test case is just.

@QuarkusTest
public class MyUnitTest{
    @Test
    public void test() {
        Assertions.assertEquals("hello Quarkus", "hello Quarkus");
    }
}

Hibernate is not needed in unit test, but it is required in my extension. So it is my problem https://github.com/quarkusio/quarkus/issues/14927#issuecomment-1087300805

Your proposal https://github.com/quarkusio/quarkus/issues/14927#issuecomment-1061830090 fits to me.

Actually I would like run quarkus test only with specified extension rather than with all extensions that exist in classpath.

0reactions
geoandcommented, Apr 26, 2022

@voronovmaksim can you please expand a little on your use case?

It sounds somewhat similar to what I had proposed in https://github.com/quarkusio/quarkus/issues/14927#issuecomment-1061830090

Read more comments on GitHub >

github_iconTop Results From Across the Web

Test experimental features in Chrome - Google Support
Open Chrome. Next to the address bar, select Experiments . Next to the feature's name and description, select the down arrow and then...
Read more >
Managing Extensions in Visual Studio Code
Discover, add, update, disable and uninstall Visual Studio Code extensions (plug-ins) through the Extension Marketplace.
Read more >
Preparing Chrome for Web Testing - SmartBear Support
To disable extensions: From the Chrome menu, select Settings and then select Extensions on the left. Clear the Enabled check box next to...
Read more >
Use group policies to manage Microsoft Edge extensions
You can use this in conjunction with the "Allow specific extensions to be installed" policy to only allow certain extensions to be installed....
Read more >
Why Proctorio requests certain browser permissions
Here is an explanation of every browser permission request a test ... allows exam administrators to “Disable Extensions” during an exam.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found