Added TestNG simple tests

This commit is contained in:
Erik C. Thauvin 2023-08-14 19:48:58 -07:00
parent 2cabdd2c63
commit 06396eb995
2 changed files with 62 additions and 3 deletions

View file

@ -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 <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
* @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");
}
}

View file

@ -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; package rife.bld.extension;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -21,7 +37,7 @@ class TestNgOperationTest {
@Test @Test
void testClass() { void testClass() {
var op = new TestNgOperation().testClass(FOO, BAR); 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 @Test
@ -45,8 +61,9 @@ class TestNgOperationTest {
@Test @Test
void testExecute() { void testExecute() {
assertThatThrownBy(() -> assertThatThrownBy(() ->
new TestNgOperation().fromProject(new Project()).packages("com.example.*").execute()) new TestNgOperation().fromProject(new Project()).packages("rife.bld.extension")
.isInstanceOf(ExitStatusException.class); .testClass("rife.bld.extension.TestNGSimpleTest")
.execute()).isInstanceOf(ExitStatusException.class);
} }
@Test @Test