Skip to content

Commit

Permalink
Simple JUnit test and runner used to create the test.yaml GHA workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
bikegeek committed Sep 17, 2024
1 parent bc7075f commit dccf6ca
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
30 changes: 30 additions & 0 deletions java/edu/ucar/metviewer/test/mvutil/TestMVUtil.java
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");
}
}




}
23 changes: 23 additions & 0 deletions java/edu/ucar/metviewer/test/mvutil/TestRunner.java
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());
}
}

0 comments on commit dccf6ca

Please sign in to comment.