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

Published: 12 May 2024
on channel: 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);
}
}

--


On this page of the site you can watch the video online How to write unit tests for java static methods in Android Studio project? with a duration of hours minute second in good quality, which was uploaded by the user Programmer World 12 May 2024, share the link with friends and acquaintances, this video has already been watched 186 times on youtube and it was liked by 3 viewers. Enjoy your viewing!