chore: move junit tests into junit package (#1480)

This commit is contained in:
Yury Semikhatsky 2024-02-08 11:56:04 -08:00 коммит произвёл GitHub
Родитель 4121a28299
Коммит dbe1d30feb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
9 изменённых файлов: 45 добавлений и 40 удалений

Просмотреть файл

@ -52,7 +52,7 @@ public class Server implements HttpHandler {
}
}
static Server createHttp(int port) throws IOException {
public static Server createHttp(int port) throws IOException {
return new Server(port, false);
}
@ -81,7 +81,7 @@ public class Server implements HttpHandler {
server.start();
}
void stop() {
public void stop() {
server.stop(0);
}

Просмотреть файл

@ -36,7 +36,7 @@ import java.util.zip.ZipInputStream;
import static org.junit.jupiter.api.Assertions.assertEquals;
class Utils {
public class Utils {
private static final AtomicInteger nextUnusedPort = new AtomicInteger(9000);
private static boolean available(int port) {
@ -47,7 +47,7 @@ class Utils {
}
}
static int nextFreePort() {
public static int nextFreePort() {
for (int i = 0; i < 100; i++) {
int port = nextUnusedPort.getAndIncrement();
if (available(port)) {

Просмотреть файл

@ -1,4 +1,4 @@
package com.microsoft.playwright;
package com.microsoft.playwright.junit;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.extension.ExtendWith;

Просмотреть файл

@ -1,5 +1,6 @@
package com.microsoft.playwright;
package com.microsoft.playwright.junit;
import com.microsoft.playwright.Server;
import org.junit.jupiter.api.extension.AfterAllCallback;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ExtensionContext;

Просмотреть файл

@ -1,18 +1,18 @@
package com.microsoft.playwright;
package com.microsoft.playwright.junit;
import com.microsoft.playwright.junit.Options;
import com.microsoft.playwright.junit.OptionsFactory;
import com.microsoft.playwright.junit.UsePlaywright;
import com.microsoft.playwright.Browser;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Server;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
import static com.microsoft.playwright.ServerLifecycle.serverMap;
import static com.microsoft.playwright.junit.ServerLifecycle.serverMap;
import static org.junit.jupiter.api.Assertions.*;
@FixtureTest
@UsePlaywright(TestPlaywrightCustomFixturesChannel.CustomOptions.class)
@UsePlaywright(TestFixtureChannelOption.CustomOptions.class)
@EnabledIf("isChannelSpecified")
public class TestPlaywrightCustomFixturesChannel {
public class TestFixtureChannelOption {
public static class CustomOptions implements OptionsFactory {
@Override

Просмотреть файл

@ -1,23 +1,27 @@
package com.microsoft.playwright;
package com.microsoft.playwright.junit;
import com.microsoft.playwright.junit.Options;
import com.microsoft.playwright.junit.OptionsFactory;
import com.microsoft.playwright.junit.UsePlaywright;
import com.microsoft.playwright.*;
import org.junit.jupiter.api.Test;
import java.util.regex.Pattern;
import static com.microsoft.playwright.ServerLifecycle.serverMap;
import static com.microsoft.playwright.junit.ServerLifecycle.serverMap;
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@FixtureTest
@UsePlaywright(TestPlaywrightCustomOptionFixtures.CustomOptions.class)
public class TestPlaywrightCustomOptionFixtures {
@UsePlaywright(TestFixtureContextOptions.CustomOptions.class)
public class TestFixtureContextOptions {
public static class CustomOptions implements OptionsFactory {
@Override
public Options getOptions() {
return new Options().setApiRequestOptions(new APIRequest.NewContextOptions().setBaseURL(serverMap.get(TestPlaywrightCustomOptionFixtures.class).EMPTY_PAGE)).setContextOption(new Browser.NewContextOptions().setBaseURL(serverMap.get(TestPlaywrightCustomOptionFixtures.class).EMPTY_PAGE));
return new Options()
.setApiRequestOptions(new APIRequest.NewContextOptions()
.setBaseURL(serverMap.get(TestFixtureContextOptions.class).EMPTY_PAGE))
.setContextOption(new Browser.NewContextOptions()
.setBaseURL(serverMap.get(TestFixtureContextOptions.class).EMPTY_PAGE));
}
}

Просмотреть файл

@ -1,17 +1,16 @@
package com.microsoft.playwright;
package com.microsoft.playwright.junit;
import com.microsoft.playwright.junit.Options;
import com.microsoft.playwright.junit.OptionsFactory;
import com.microsoft.playwright.junit.UsePlaywright;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Server;
import org.junit.jupiter.api.Test;
import static com.microsoft.playwright.ServerLifecycle.serverMap;
import static com.microsoft.playwright.junit.ServerLifecycle.serverMap;
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
@FixtureTest
@UsePlaywright(TestPlaywrightDeviceOption.CustomOptions.class)
public class TestPlaywrightDeviceOption {
@UsePlaywright(TestFixtureDeviceOption.CustomOptions.class)
public class TestFixtureDeviceOption {
public static class CustomOptions implements OptionsFactory {
@Override

Просмотреть файл

@ -1,30 +1,31 @@
package com.microsoft.playwright;
package com.microsoft.playwright.junit;
import com.microsoft.playwright.junit.Options;
import com.microsoft.playwright.junit.OptionsFactory;
import com.microsoft.playwright.junit.UsePlaywright;
import com.microsoft.playwright.Browser;
import com.microsoft.playwright.Page;
import org.junit.jupiter.api.Test;
import java.util.regex.Pattern;
import static com.microsoft.playwright.ServerLifecycle.serverMap;
import static com.microsoft.playwright.junit.ServerLifecycle.serverMap;
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
@FixtureTest
@UsePlaywright(TestPlaywrightCustomFixtures.CustomOptions.class)
public class TestPlaywrightCustomFixtures {
@UsePlaywright(TestFixtureOptions.CustomOptions.class)
public class TestFixtureOptions {
public static class CustomOptions implements OptionsFactory {
@Override
public Options getOptions() {
return new Options().setBaseUrl(serverMap.get(TestPlaywrightCustomFixtures.class).EMPTY_PAGE).setBrowserName("firefox");
return new Options()
.setBaseUrl(serverMap.get(TestFixtureOptions.class).EMPTY_PAGE)
.setBrowserName("webkit");
}
}
@Test
public void testCustomBrowser(Browser browser) {
assertEquals(browser.browserType().name(), "firefox");
assertEquals(browser.browserType().name(), "webkit");
}
@Test

Просмотреть файл

@ -1,6 +1,6 @@
package com.microsoft.playwright;
package com.microsoft.playwright.junit;
import com.microsoft.playwright.junit.UsePlaywright;
import com.microsoft.playwright.*;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
@UsePlaywright
public class TestPlaywrightFixtures {
public class TestFixtures {
private static Playwright playwrightFromBeforeAll;
private static Browser browserFromBeforeAll;
private BrowserContext browserContextFromBeforeEach;