Code Monkey home page Code Monkey logo

Comments (3)

autonomousapps avatar autonomousapps commented on May 23, 2024 12

Actually, turns out it wasn't so hard to replace that particular rule. Here it is:

class InstantTaskExecutorExtension : BeforeEachCallback, AfterEachCallback {

    override fun beforeEach(context: ExtensionContext) {
        ArchTaskExecutor.getInstance().setDelegate(object : TaskExecutor() {
            override fun executeOnDiskIO(runnable: Runnable) {
                runnable.run()
            }

            override fun postToMainThread(runnable: Runnable) {
                runnable.run()
            }

            override fun isMainThread(): Boolean {
                return true
            }
        })
    }

    override fun afterEach(context: ExtensionContext?) {
        ArchTaskExecutor.getInstance().setDelegate(null)
    }
}

from android-junit5.

mannodermaus avatar mannodermaus commented on May 23, 2024

Great to see you dived into the Extension sphere yourself already! With the instrumentation test support, I intend to provide replacements for core JUnit 4 APIs that evolve to become Extensions. Since this particular class is tied to Architecture Components, I won't include it into the core instrumentation-test library. However, this could become its own library for people to plug into their project eventually. For now, I'll consider to link to this for the upcoming wiki on usage with Instrumentation Tests. Thank you!

from android-junit5.

autonomousapps avatar autonomousapps commented on May 23, 2024

I can confirm that extension works perfectly in my unit test suite. I'll keep an eye on this project and contribute any other extensions I come across (actually, I already have one to enable the @Mock annotation, but I found that elsewhere). I'm sure some way or other we'll end up with some test libs to share!

from android-junit5.

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.