Migrate tests to JUnit 5 (#8519)

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born
2020-09-21 18:21:26 +02:00
committed by GitHub
parent 6df6783b60
commit bd82ca82df
478 changed files with 3996 additions and 4419 deletions

View File

@@ -12,15 +12,15 @@
*/
package org.openhab.binding.astro.internal.calc;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.TimeZone;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.openhab.binding.astro.internal.model.Sun;
import org.openhab.binding.astro.internal.model.SunPhaseName;
@@ -51,7 +51,7 @@ public class SunCalcTest {
private SunCalc sunCalc;
@Before
@BeforeEach
public void init() {
sunCalc = new SunCalc();
}
@@ -178,7 +178,7 @@ public class SunCalcTest {
}
@Test
@Ignore
@Disabled
public void testRangesForCoherenceBetweenNightEndAndAstroDawnStart() {
Sun sun = sunCalc.getSunInfo(FEB_27_2019, AMSTERDAM_LATITUDE, AMSTERDAM_LONGITUDE, AMSTERDAM_ALTITUDE, false);

View File

@@ -12,12 +12,12 @@
*/
package org.openhab.binding.astro.internal.model;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import java.time.ZoneId;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openhab.binding.astro.internal.config.AstroChannelConfig;
import org.openhab.binding.astro.internal.util.PropertyUtils;
import org.openhab.core.library.types.StringType;
@@ -39,7 +39,7 @@ public class SunTest {
private static ZoneId ZONE = ZoneId.systemDefault();
@Before
@BeforeEach
public void init() {
sun = new Sun();
config = new AstroChannelConfig();
@@ -68,13 +68,14 @@ public class SunTest {
PropertyUtils.getState(new ChannelUID("astro:sun:home:phase#name"), config, sun, ZONE));
}
@Test(expected = NullPointerException.class)
@Test
public void testGetStateWhenNullPhase() throws Exception {
sun.setPhase(null);
assertNull(sun.getPhase());
assertEquals(UnDefType.UNDEF,
PropertyUtils.getState(new ChannelUID("astro:sun:home:phase#name"), config, sun, ZONE));
assertThrows(NullPointerException.class, () -> assertEquals(UnDefType.UNDEF,
PropertyUtils.getState(new ChannelUID("astro:sun:home:phase#name"), config, sun, ZONE)));
}
@Test