Coder Social home page Coder Social logo

Comments (5)

rob-bygrave avatar rob-bygrave commented on August 25, 2024 1

@mock Service mocky; //<- doesn't get added to beanscope

Right, so the HttpClient is static scope ... and that means that the http server that it will hit/access is also "wired" to the static scope.

So the @Mock Service mocky will be injected as a mock into the instance scope ... but IF the test is using the httpClient, that httpClient will hit the static scoped server instance which will NOT include that mock.

If it was the other way around [in terms of static scope and instance scope] like:

 @Inject HttpClient client;
 static @Mock Service mocky;

Or the same scope [both static or both instance scope] ... then tests can use both.

doesn't get added to beanscope

This statement is NOT correct. It is getting added to a beanScope ... it's that there are MULTIPLE BeanScopes (the static one and the instance one). The static scoped HttpClient will hit the static scoped Helidon instance (and that instance is created once at static class beforeAll time ...

from avaje-nima.

SentryMan avatar SentryMan commented on August 25, 2024

hmm, would this be an inject bug or an avaje nima bug?

from avaje-nima.

SentryMan avatar SentryMan commented on August 25, 2024

once again, the error is mine, it seems I get it working if I don't add static when injecting the client

from avaje-nima.

rob-bygrave avatar rob-bygrave commented on August 25, 2024

it seems I get it working if I don't add static when injecting the client

This does not make sense to me in that both static and non-static/instance are valid scopes.

Did this test use @Mock or @Inject? It could be that I'm assuming HttpClient is used with @Inject and maybe that is confusing ?

from avaje-nima.

SentryMan avatar SentryMan commented on August 25, 2024

Did this test use @mock or @Inject? It could be that I'm assuming HttpClient is used with @Inject and maybe that is confusing ?

looked like this:

@InjectTest
TestyMcTest {
 @Inject static HttpClient client;
 @Mock Service mocky; //<- doesn't get added to beanscope
}

from avaje-nima.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.