Search result for Question Taged junit5
There are some results of your Tag: junit5
    How to deal with deprecated gradle features were used in this build, making it incompatible with gradle 8.0

    1. FAILURE
    2. Sometime when you try to build the app you may encounter this FAILURE.
      ..."Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0."
      

    3. Most common Solution
    4. Run the Gradle build with a command line argument --warning-mode=all to see what exactly the deprecated features are.

      It will give you a detailed description of found issues with links to the Gradle docs for instructions how to fix your build.

      Adding --stacktrace to that, you will also be able to pinpoint where the warning comes from, if it's triggered by outdated code in one of the plugins and not your build script.

    5. Solution 2
    6. if the abouve Solution dont work Try this one

      cd android && ./gradlew clean && ./gradlew :app:bundleRelease
      

    7. Solution 3
    8. The process below worked in many case- First check Gradle Version:

      cd android
      ./gradlew -v
      

      In my case it was 6.5

      Go to https://developer.android.com/studio/releases/gradle-plugin and you'll get the plugin version for your gradle version. For gradle version 6.5, the plugin version is 4.1.0

      Then go to app/build.gradle and change classpath 'com.android.tools.build:gradle:<plugin_version>

    9. Solution 4
    10. if your project is incompatible with Gradle 8.0 .Here's what worked for you: First write this line of code in the Android Studio terminal:

      ./gradlew build --warning-mode all
      

      When you do that, you will be shown in the logcat what is found to be deprecated or an issue in your project, for me it was the jcenter() repository that needed to be removed in my settings.gradle file and also I needed to update classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21" to classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30" in my build.gradle project file.

      Once I did these things, my project built perfectly and installed on my emulator

    Kyle Elkins 2022-08-09
    android - JUnit5IdeaTestRunner fails running unit tests

    Suddenly Android Studio can't run unit tests for one of my modules. I get the error:

    Internal Error occurred. java.util.NoSuchElementException
    at java.util.ArrayList$Itr.next(ArrayList.java:856)
    at java.util.Collections$UnmodifiableCollection$1.next(Collections.java:1042)
    at com.intellij.junit5.JUnit5TestRunnerUtil.createSelector(JUnit5TestRunnerUtil.java:181)
    at com.intellij.junit5.JUnit5TestRunnerUtil.buildRequest(JUnit5TestRunnerUtil.java:70)
    at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:51)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
    

    The only thing I need to know is whether this is a known issue.
    Please notice that the unit tests of all the modules succeed if I run them in the external terminal or in the terminal in Android Studio or on the CI.
    And if I run on Android Studio the same unit test configuration, changing only the module then everything works fine.

    Please don't ask me to post the build.gradle files. Although it is likely that the problem is there, they are too big and more importantly if that is the problem, I wouldn't expect you to debug it.

    Nandita Maud 2022-11-01
    android - How to Store Values in JUnit 5 Extensions and Inject in Parameterized Test

    Overview

    Expected - Create a JUnit 5 Extension class in order to manage use of a TestCoroutineDispatcher.

    Observed - Unable to access the testDispatcher variable created within the Extension class.

    Extension Implementation

    Test.kt

    
    @ExtendWith(InstantExecutorExtension::class, MainCoroutineExtension::class)
    class FeedLoadContentTests {
        private val contentViewModel = ContentViewModel()
        private fun FeedLoad() = feedLoadTestCases()
    
        @ParameterizedTest
        @MethodSource("FeedLoad")
        @ExtendWith(MainCoroutineExtension::class)
        fun `Feed Load`(test: FeedLoadContentTest) = testDispatcher.runBlockingTest {
            // Some testing done here.
        }
    }
    

    Extension.kt

    class MainCoroutineExtension : BeforeEachCallback, AfterEachCallback {
        val testDispatcher = TestCoroutineDispatcher()
    
        override fun beforeEach(context: ExtensionContext?) {
            Dispatchers.setMain(testDispatcher)
        }
    
        override fun afterEach(context: ExtensionContext?) {
            Dispatchers.resetMain()
            testDispatcher.cleanupTestCoroutines()
        }
    }
    
    Nadra Serapion 2022-12-01