Giter VIP home page Giter VIP logo

Comments (4)

snicoll avatar snicoll commented on June 12, 2024 1

All things considered, we don't believe this to be a good change. It's more consistent to do what the users has defined in their configuration, for consistency with what's happening with production code. For hierarchical test cases, like this one, inheritLocations should be used to disable what's coming from the parent if necessary.

from spring-framework.

sbrannen avatar sbrannen commented on June 12, 2024

Code related to this can be found in:

  • AbstractTestContextBootstrapper.buildMergedContextConfiguration(Class<?>, List<ContextConfigurationAttributes>, MergedContextConfiguration, CacheAwareContextLoaderDelegate, boolean)
  • MergedContextConfiguration.processStrings(String[])

from spring-framework.

andrea-mauro avatar andrea-mauro commented on June 12, 2024

Do you think following a similar approach to what's done on activeProfiles would work? You can see this proposal in the branch above

from spring-framework.

sbrannen avatar sbrannen commented on June 12, 2024

Do you think following a similar approach to what's done on activeProfiles would work?

No, I think it's unfortunately a bit more involved than that. Otherwise, we would have enforced uniqueness with a LinkedHashSet for both the locations and classes a long time ago.

Our goal here is actually not to enforce uniqueness within the entire set of locations or classes, because the duplicate presence of a configuration location or class can be intentional (or at least necessary) due to nuances of the overall configuration -- for example, because that's how the production application works. (Note: I'm not saying that any form of duplication is ideal, but I recall that we didn't go for strict uniqueness because of certain use cases in the wild.)

Rather, we want to detect when a certain class in the test class hierarchy declares the same set of locations or classes, in the exact same order, as its superclass. If we detect such accidental duplication, we then want to remove the duplication.

As I hinted at in my previous comment, we would likely need to build that logic into AbstractTestContextBootstrapper.buildMergedContextConfiguration(...).


As a side note, I suppose we would also want to remove any adjacent, duplicate configuration locations or classes.

For example, @ContextConfiguration(locations = {"config1.xml", "config1.xml", "config2.xml"}) and @ContextConfiguration(classes = {"Config1", "Config1", "Config2"}) should probably never load config1.xml and Config1 twice.

from spring-framework.

Related Issues (20)

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.