EILMELDUNGEN LIVE
🕵️ SicherheitslückenMySQL Governance(26.08.2026 um 19:58 Uhr)
⚠️ PoCNative ANN Vector Indexing in InnoDB(26.08.2026 um 20:09 Uhr)
🔧 ProgrammierungWhat's the coolest thing coming in the next version of C#?(27.08.2026 um 18:00 Uhr)
🔧 ProgrammierungWhat's the coolest thing coming in the next version of C#?(27.08.2026 um 18:00 Uhr)
🔧 ProgrammierungYour first AI agent is only a few lines of Python away(02.09.2026 um 00:34 Uhr)
🔧 AI Nachrichten Der HuggingFace-Hack ist jetzt untersucht(28.08.2026 um 15:57 Uhr)
🔧 AI Nachrichten Details zum OpenAI-HuggingFace-Hack(01.09.2026 um 17:36 Uhr)
🕵️ SicherheitslückenMySQL Governance(26.08.2026 um 19:58 Uhr)
⚠️ PoCNative ANN Vector Indexing in InnoDB(26.08.2026 um 20:09 Uhr)
🔧 ProgrammierungWhat's the coolest thing coming in the next version of C#?(27.08.2026 um 18:00 Uhr)
🔧 ProgrammierungWhat's the coolest thing coming in the next version of C#?(27.08.2026 um 18:00 Uhr)
🔧 ProgrammierungYour first AI agent is only a few lines of Python away(02.09.2026 um 00:34 Uhr)
🔧 AI Nachrichten Der HuggingFace-Hack ist jetzt untersucht(28.08.2026 um 15:57 Uhr)
🔧 AI Nachrichten Details zum OpenAI-HuggingFace-Hack(01.09.2026 um 17:36 Uhr)
1 Tag Serie
12 🕛 kürzlich 5 Min Lesezeit CVE-RADAR
0

Leveraging product flavors in Android Studio for hermetic testing

↗ Quelle (feedproxy.google.com)
🗣️ Stimme:
📑 Inhaltsübersicht
📺
feedproxy.google.com

Posted by , Developer Advocate




During our recent talk at Android Dev Summit, we discuss the state of testing on Android on the example of a simple Notes application that we created as part of our testing . In one section of the talk, we discuss the problem of test flakiness and introduce a simple solution for setting up a hermetic testing environment.



Combatting flaky tests



UI tests with frameworks like Espresso or UI Automator can easily get flaky if the application has external dependencies that can sometimes fail or take long to respond. In short, flaky tests are tests that are not reliable (they can pass or fail randomly) which defeats the whole purpose of having tests in the first place.



A common solution to this problem is hermetic testing or, in other words, making sure that your tests are isolated from dependencies. Using fake implementations or fake servers that just return predefined data is a common way of dealing with this problem. Here are some good examples:



  • Network calls can be made via a fake API client or fake server that immediately returns data from files stored on disk instead of hitting the network. This bypasses the network's latency and flakiness as well as any errors originating on the real server.

  • Interactions with low-level framework APIs (especially those for accessing hardware, like camera or storage) can be passed through an intermediate interface. A fake implementation of this interface could return immediately, providing a reference to preloaded data, such as an image, without relying on the hardware.

  • Any sensors can be replaced with fakes too: GPS, microphone, accelerometer etc., giving you a chance to test on data that would be difficult to provide for the test in real life, like a preset location or a set of inputs simulating a gesture.

Dependency Injection (DI) is a software design pattern that facilitates testing, reusing modules and making them interchangeable. DI frameworks can help you deal with the boilerplate associated with this pattern but it can take a considerable amount of time to set them up and understand how they work. Before you are ready to commit to one of those frameworks for your app, you might want to explore an easier way, especially if your project requirements are simple.



Managing dependencies with product flavors




  • Create the class that you want to use for production code in the prod/java folder or move it from main/java. Make sure the main/java folder does not contain this class.
  • Create the same class (with the exact same class and file name) in the mock/java folder, but providing a different (fake) implementation that will be used for tests.
  • In the Build Variants window in Android Studio, choose the variant that you want to install or run tests against. A variant is the combination of a flavor and a build type.
  • to see how we used this method to provide different Injection class implementations, the one in providing real data and the other (
    Vollständiger Original-Bericht
    Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf feedproxy.google.com.
    ↗ Original-Artikel auf feedproxy.google.com lesen
    Wie bewertest du diesen Beitrag?
    1 Klick Feedback
    57 Fachleser & IT-Security Experten haben diesen Report heute geteilt
    Teilen mit Netzwerk & Team:

    Community-Analysen & Experten-Meinungen 0

    Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
    Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
    Community Pulse: Relevanz-Einschätzung
    1 Klick Experten-Votum
    🔴 Akute Relevanz 49%
    🟡 In Evaluierung 24%
    🟢 Keine Auswirkung 14%
    Spannende Innovation 13%
    Verwandte Story-Cluster & Quellen (Vektor-KI)
    Port 8095 Engine
    2 Quellen
    Homey Portal: Smart Home Controller für die Smart Home Zentrale
    1 Quelle
    Etappe: Digitaler Reisebegleiter für den nächsten Roadtrip
    1 Quelle
    iPhone Ultra höchstwahrscheinlich mit MagSafe
    Ähnliche Beiträge
    🔍 Verwandte News

    Ähnliche Beiträge zu Leveraging product flavors in Android Studio for hermetic testing

    Thematisch verwandte Begriffe: Leveraging, product, flavors, Android · 6 Treffer

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...