Skip to content

Commit

Permalink
chore(tests): fix broken AbstractSuiteTest
Browse files Browse the repository at this point in the history
  • Loading branch information
aanorbel committed Jul 17, 2024
1 parent 8fe1177 commit fdc7895
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,15 @@ enum class OONITests(
this.run {
return OONIDescriptor(
name = label,
title = context.getString(title),
shortDescription = context.getString(shortDescription),
title = r.getString(title),
shortDescription = r.getString(shortDescription),
description = when (label) {
EXPERIMENTAL.label -> context.getString(
EXPERIMENTAL.label -> r.getString(
description,
experimentalLinks(r)
)

else -> context.getString(description)
else -> r.getString(description)
},
icon = icon,
color = ContextCompat.getColor(context, color),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@

import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.openobservatory.ooniprobe.test.suite.AbstractSuiteExtensionsKt.getSuite;

import android.content.res.Resources;

public class AbstractSuiteTest {
private final Application app = mock(Application.class);

private final Resources mockContextResources = mock(Resources.class);

private AbstractSuite suite = new AbstractSuite(
"test",
"",
Expand All @@ -42,6 +48,10 @@ public class AbstractSuiteTest {
@Before
public void setUp() {
when(app.getPreferenceManager()).thenReturn(pm);
when(app.getResources()).thenReturn(mockContextResources);
when(mockContextResources.getString(anyInt())).thenReturn("mocked string");
when(mockContextResources.getString(anyInt(),any())).thenReturn("mocked string");

}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.openobservatory.ooniprobe.test.suite;

import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openobservatory.ooniprobe.common.Application;
Expand All @@ -22,8 +23,8 @@ public class ExperimentalSuiteTest {
private final AbstractSuite autoRunSuite = OONITests.EXPERIMENTAL.toOONIDescriptor(app).getTest(app);
private final PreferenceManager pm = mock(PreferenceManager.class);

@BeforeClass
public void setUp() {
@Before
public void setUp() {
autoRunSuite.setAutoRun(true);
}
@Test
Expand Down

0 comments on commit fdc7895

Please sign in to comment.