From 06396eb9957fe39551e24e7f3b9e8e239a0ead27 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 14 Aug 2023 19:48:58 -0700 Subject: [PATCH] Added TestNG simple tests --- .../rife/bld/extension/TestNGSimpleTest.java | 42 +++++++++++++++++++ .../bld/extension/TestNgOperationTest.java | 23 ++++++++-- 2 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 src/test/java/rife/bld/extension/TestNGSimpleTest.java diff --git a/src/test/java/rife/bld/extension/TestNGSimpleTest.java b/src/test/java/rife/bld/extension/TestNGSimpleTest.java new file mode 100644 index 0000000..910638b --- /dev/null +++ b/src/test/java/rife/bld/extension/TestNGSimpleTest.java @@ -0,0 +1,42 @@ +/* + * Copyright 2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package rife.bld.extension; + +import org.testng.Assert; +import org.testng.annotations.Test; + +/** + * Implements the TestNGSimpleTest class. + * + * @author Erik C. Thauvin + * @since 1.0 + */ +class TestNGSimpleTest { + public static void main(String[] args) { + new TestNGSimpleTest().verifyHello(); + } + + @Test + void verifyHello() { + Assert.assertTrue(true); + } + + @Test + void testFail() { + Assert.fail("failed"); + } +} diff --git a/src/test/java/rife/bld/extension/TestNgOperationTest.java b/src/test/java/rife/bld/extension/TestNgOperationTest.java index c4024db..399c971 100644 --- a/src/test/java/rife/bld/extension/TestNgOperationTest.java +++ b/src/test/java/rife/bld/extension/TestNgOperationTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package rife.bld.extension; import org.junit.jupiter.api.Test; @@ -21,7 +37,7 @@ class TestNgOperationTest { @Test void testClass() { var op = new TestNgOperation().testClass(FOO, BAR); - assertThat(op.options().get("-testclass")).isEqualTo(String.format("%s,%s", FOO, BAR)); + assertThat(op.options().get(TestNgOperation.TEST_CLASS_ARG)).isEqualTo(String.format("%s,%s", FOO, BAR)); } @Test @@ -45,8 +61,9 @@ class TestNgOperationTest { @Test void testExecute() { assertThatThrownBy(() -> - new TestNgOperation().fromProject(new Project()).packages("com.example.*").execute()) - .isInstanceOf(ExitStatusException.class); + new TestNgOperation().fromProject(new Project()).packages("rife.bld.extension") + .testClass("rife.bld.extension.TestNGSimpleTest") + .execute()).isInstanceOf(ExitStatusException.class); } @Test