-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature 539 add test workflow (#548)
* added the test.yaml for initial JUnit tests and changed filenames of the other GHA workflow files to conform with the rest of METplus * Issue #539 add this jar to enable GHA to run junit * Issue #539 including the edu/ucar/metviewer/test/mvutil/*.java to the target "compile-all" * Test if junit command works * Fixed syntax error * Added test-compile and test to facilitate JUnit4 tests * Use test-compile and test target in the command * use ant test command instead of java -jar to run junit test * fix lib to ${lib} for junit jar and modify some paths for the test build dir * modify the ant command to run the test * remove incorrect/unused ant command for compiling tests * explicitly point to the MVUtil tests * experiment with running the junit-platform-console-standalone jar * Separate the first run command into building the tests * Added some useful comments, cleaning up * Simple JUnit test and runner used to create the test.yaml GHA workflow
- Loading branch information
Showing
8 changed files
with
131 additions
and
1 deletion.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# This workflow will build a Java project with Ant | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-ant | ||
|
||
name: JUnit CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
- develop-ref | ||
- feature_* | ||
- issue_* | ||
- main_* | ||
- bugfix_* | ||
pull_request: | ||
types: [opened, reopened, synchronize] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '11' | ||
distribution: 'temurin' | ||
- name: Build MV JUnit tests | ||
run: ant clean test -verbose -noinput | ||
- name: Run MV JUnit tests | ||
run: java -jar lib/junit-platform-console-standalone-1.4.0.jar --select-package edu.ucar.metviewer.test.mvutiljava |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package edu.ucar.metviewer.test.mvutil; | ||
|
||
import edu.ucar.metviewer.MVUtil; | ||
import org.junit.Test; | ||
|
||
import org.junit.runner.notification.Failure; | ||
import org.w3c.dom.Document; | ||
|
||
|
||
|
||
import static org.junit.Assert.*; | ||
|
||
|
||
public class TestMVUtil { | ||
@Test | ||
public void testCreateDocument(){ | ||
try{ | ||
System.out.println("Testing CreateDocument..."); | ||
assertTrue(MVUtil.createDocument() instanceof Document ); | ||
assertTrue(MVUtil.createDocument() != null); | ||
|
||
}catch (javax.xml.parsers.ParserConfigurationException e){ | ||
fail("ParserConfigurationException was raised while creating a document"); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package edu.ucar.metviewer.test.mvutil; | ||
|
||
import com.sun.net.httpserver.Authenticator; | ||
import org.junit.runner.JUnitCore; | ||
import org.junit.runner.Result; | ||
import org.junit.runner.notification.Failure; | ||
|
||
|
||
// Useful for running from the command line | ||
|
||
|
||
public class TestRunner { | ||
public static void main(String[] args){ | ||
Result result = JUnitCore.runClasses(TestMVUtil.class); | ||
|
||
for (Failure failure : result.getFailures()){ | ||
System.out.println(failure.toString()); | ||
} | ||
|
||
System.out.println("Tests pass: "+ result.wasSuccessful() + "\nNumber of runs: " + | ||
result.getRunCount()); | ||
} | ||
} |
Binary file not shown.