How to write unit tests for java static methods in Android Studio project?

Pubblicato il: 12 maggio 2024
sul canale di: Programmer World
186
3

In this video, it shows the steps to create java unit test for static methods of Android Studio Project.


I hope you like this video. For any questions, suggestions or appreciation please contact us at: https://programmerworld.co/contact/ or email at: programmerworld1990@gmail.com

Complete source code and other details/ steps of this video are posted in the below link:
https://programmerworld.co/android/ho...


However, the main Java code is copied below also for reference:

package com.programmerworld.unittestsforstaticmethod;

import org.junit.Test;
import static org.junit.Assert.*;

public class ExampleUnitTest {
private MainActivity activity;
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}

@Test
public void testStaticAdditionMethod(){
double result = activity.staticAdditionMethod(4,5);
assertEquals(9,result,0.0001);
}
}

--


In questa pagina del sito puoi guardare il video online How to write unit tests for java static methods in Android Studio project? della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Programmer World 12 maggio 2024, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 186 volte e gli è piaciuto 3 spettatori. Buona visione!