Skip to content

Commit

Permalink
Fix Unit Test Failures (#49)
Browse files Browse the repository at this point in the history
* address jacoco failures

* heap analysis showed that were thousands of structure definitions and value sets being loaded - new version creates a new validator for each test and deletes it afterwards to keep heap space minimal

Co-authored-by: Passas <[email protected]>
  • Loading branch information
ms-k1ngk0ng and Passas authored Jul 14, 2022
1 parent 88d0c0a commit 8c398c4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ gradle-app.setting

# IDE
.idea
.vscode
settings.json

# Mac Stuff
.DS_Store
10 changes: 10 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,21 @@ checkstyle {
toolVersion = "8.25"
}

jacoco {
toolVersion = "0.8.8"
}

tasks.test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
configure<JacocoTaskExtension> {
excludes = mutableListOf("org/hl7/fhir/r4/formats/JsonParser",
"org/hl7/fhir/r5/formats/JsonParser",
"org/hl7/fhir/r4/formats/XmlParser",
"org/hl7/fhir/r5/formats/XmlParser")
}
}

val testCoverage by tasks.registering {
Expand Down
16 changes: 10 additions & 6 deletions src/test/java/org/mitre/inferno/ValidatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,25 @@
import java.util.List;
import java.util.Set;
import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mitre.inferno.rest.IgResponse;


public class ValidatorTest {
private static Validator validator;

@BeforeAll
static void setUp() throws Exception {
@BeforeEach
public void setUp() throws Exception {
validator = new Validator("./igs");
}

@AfterEach
public void cleanUp() throws Exception {
validator = null;
}

@Test
void getStructures() {
boolean condition = validator
Expand Down Expand Up @@ -82,7 +88,7 @@ void validate() {
fail();
}
}

@Test
void validateMultipleProfiles() {
try {
Expand All @@ -105,8 +111,6 @@ void loadIg() throws Exception {
List<String> profilesToLoad = Arrays.asList(
"http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-comorbidities-parent",
"http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-cancer-disease-status",
"http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-cancer-genetic-variant",
"http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-cancer-genomics-report",
"http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-cancer-patient",
"http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-cancer-related-medication-request",
"http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-cancer-related-surgical-procedure",
Expand Down

0 comments on commit 8c398c4

Please sign in to comment.