Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion History.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
2.0.24 / 2026-??-??
==================
* Upgrade closure-compiler v20260128 to v20260406, Rhino 1.9.0 to 1.9.1
* Internal: Mockito 5.20.0 to 5.23.0, JUnit 4.13.2 to JUnit 5.14.3
* Internal: Mockito 5.20.0 to 5.23.0, JUnit 4.13.2 to JUnit 6.0.3, Hamcrest 3.0 to AssertJ 3.27.7

2.0.23 / 2026-02-10
==================
Expand Down
5 changes: 2 additions & 3 deletions JSCover.iml
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.1.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.jspecify:jspecify:1.0.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-junit-jupiter:5.23.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:3.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest:3.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.27.7" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy:1.18.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:5.23.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy:1.17.7" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.17.7" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:3.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.jacoco:org.jacoco.ant:0.8.14" level="project" />
Expand Down
32 changes: 10 additions & 22 deletions JSCover.ipr
Original file line number Diff line number Diff line change
Expand Up @@ -810,16 +810,16 @@
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy-agent/1.17.7/byte-buddy-agent-1.17.7-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: net.bytebuddy:byte-buddy:1.17.7" type="java-imported" external-system-id="Maven">
<properties groupId="net.bytebuddy" artifactId="byte-buddy" version="1.17.7" baseVersion="1.17.7" />
<library name="Maven: net.bytebuddy:byte-buddy:1.18.3" type="java-imported" external-system-id="Maven">
<properties groupId="net.bytebuddy" artifactId="byte-buddy" version="1.18.3" baseVersion="1.18.3" />
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy/1.17.7/byte-buddy-1.17.7.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy/1.18.3/byte-buddy-1.18.3.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy/1.17.7/byte-buddy-1.17.7-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy/1.18.3/byte-buddy-1.18.3-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy/1.17.7/byte-buddy-1.17.7-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy/1.18.3/byte-buddy-1.18.3-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.apache.commons:commons-lang3:3.20.0" type="java-imported" external-system-id="Maven">
Expand Down Expand Up @@ -882,28 +882,16 @@
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.hamcrest:hamcrest-core:3.0" type="java-imported" external-system-id="Maven">
<properties groupId="org.hamcrest" artifactId="hamcrest-core" version="3.0" baseVersion="3.0" />
<library name="Maven: org.assertj:assertj-core:3.27.7" type="java-imported" external-system-id="Maven">
<properties groupId="org.assertj" artifactId="assertj-core" version="3.27.7" baseVersion="3.27.7" />
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/3.0/hamcrest-core-3.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/assertj/assertj-core/3.27.7/assertj-core-3.27.7.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/3.0/hamcrest-core-3.0-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/assertj/assertj-core/3.27.7/assertj-core-3.27.7-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/3.0/hamcrest-core-3.0-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.hamcrest:hamcrest:3.0" type="java-imported" external-system-id="Maven">
<properties groupId="org.hamcrest" artifactId="hamcrest" version="3.0" baseVersion="3.0" />
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest/3.0/hamcrest-3.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest/3.0/hamcrest-3.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest/3.0/hamcrest-3.0-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/assertj/assertj-core/3.27.7/assertj-core-3.27.7-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.htmlunit:htmlunit-core-js:4.21.0" type="java-imported" external-system-id="Maven">
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>3.0</version>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.27.7</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
1 change: 0 additions & 1 deletion src/main/java/jscover/instrument/CommentsHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ You should also get your employer (if you work as a programmer) or your

package jscover.instrument;


import com.google.javascript.jscomp.parsing.parser.trees.Comment;

import java.util.HashSet;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/jscover/report/BranchData.java
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ You should also get your employer (if you work as a programmer) or your

package jscover.report;


import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down
1 change: 0 additions & 1 deletion src/main/java/jscover/server/HttpRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ You should also get your employer (if you work as a programmer) or your

package jscover.server;


import java.io.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,7 @@ You should also get your employer (if you work as a programmer) or your
import java.io.File;
import java.io.IOException;

import static org.hamcrest.CoreMatchers.endsWith;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.assertj.core.api.Assertions.assertThat;

public class MainGenerateFileAcceptanceTest {
private IoUtils ioUtils = IoUtils.getInstance();
Expand All @@ -372,10 +370,10 @@ public void shouldGenerateReportFiles() throws IOException {
File jsCoverHtml = new File(reportDir, "jscoverage.html");
File jsCoverJS = new File(reportDir, "jscoverage.js");
File origSrc = new File(reportDir, Main.reportSrcSubDir);
assertThat(jsCoverHtml.exists(), is(true));
assertThat(jsCoverJS.exists(), is(true));
assertThat(origSrc.exists(), is(false));
assertThat(ioUtils.loadFromFileSystem(jsCoverJS), endsWith("\njscoverage_isReport = true;"));
assertThat(jsCoverHtml.exists()).isTrue();
assertThat(jsCoverJS.exists()).isTrue();
assertThat(origSrc.exists()).isFalse();
assertThat(ioUtils.loadFromFileSystem(jsCoverJS)).endsWith("\njscoverage_isReport = true;");
}

@Test
Expand All @@ -388,10 +386,10 @@ public void shouldGenerateReportFilesWithOriginalSource() throws IOException {
File jsCoverHtml = new File(reportDir, "jscoverage.html");
File jsCoverJS = new File(reportDir, "jscoverage.js");
File origSrc = new File(reportDir, Main.reportSrcSubDir);
assertThat(jsCoverHtml.exists(), is(true));
assertThat(jsCoverJS.exists(), is(true));
assertThat(new File(origSrc, "script.js").exists(), is(true));
assertThat(ioUtils.loadFromFileSystem(jsCoverJS), endsWith("\njscoverage_isReport = true;"));
assertThat(jsCoverHtml.exists()).isTrue();
assertThat(jsCoverJS.exists()).isTrue();
assertThat(new File(origSrc, "script.js").exists()).isTrue();
assertThat(ioUtils.loadFromFileSystem(jsCoverJS)).endsWith("\njscoverage_isReport = true;");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,7 @@ You should also get your employer (if you work as a programmer) or your
import java.io.File;
import java.io.IOException;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class HtmlUnitFileSystemTest {
Expand All @@ -373,10 +372,10 @@ public void shouldWorkWithFileSystem() throws Exception {
Main.main(args);

String noInstrumentJS = ioUtils.loadFromFileSystem(new File(reportDir+"/example/lib/noInstrument.js"));
assertThat(noInstrumentJS, equalTo("alert('Hey');"));
assertThat(noInstrumentJS).isEqualTo("alert('Hey');");

assertThat(new File(reportDir+"/example/script.js").exists(), equalTo(true));
assertThat(new File(reportDir+"/example/noCopy/test.txt").exists(), equalTo(false));
assertThat(new File(reportDir+"/example/script.js").exists()).isEqualTo(true);
assertThat(new File(reportDir+"/example/noCopy/test.txt").exists()).isEqualTo(false);

HtmlPage page = webClient.getPage(getFileURL(reportDir + "/jscoverage.html?example/index.html"));
verifyTotal(webClient, page, 15);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,18 +344,14 @@ You should also get your employer (if you work as a programmer) or your

import jscover.util.IoUtils;
import org.apache.commons.io.FileUtils;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.io.File;
import java.io.IOException;
import java.util.Properties;

import static org.hamcrest.CoreMatchers.endsWith;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.assertj.core.api.Assertions.assertThat;

public class MainReportMergeAcceptanceTest {
private IoUtils ioUtils = IoUtils.getInstance();
Expand Down Expand Up @@ -386,25 +382,25 @@ public void shouldGenerateReportFiles() throws IOException {
properties.load(jscover.Main.class.getResourceAsStream("/jscover/configuration.properties"));
Main.main(args);
File jsCoverHtml = new File(reportDir12, "jscoverage.html");
assertThat(jsCoverHtml.exists(), is(true));
assertThat(jsCoverHtml.exists()).isTrue();
File jsCoverJS = new File(reportDir12, "jscoverage.js");
assertThat(jsCoverJS.exists(), is(true));
assertThat(ioUtils.loadFromFileSystem(jsCoverHtml), Matchers.containsString(properties.getProperty("version")));
assertThat(ioUtils.loadFromFileSystem(jsCoverJS), endsWith("\njscoverage_isReport = true;"));
assertThat(jsCoverJS.exists()).isTrue();
assertThat(ioUtils.loadFromFileSystem(jsCoverHtml)).contains(properties.getProperty("version"));
assertThat(ioUtils.loadFromFileSystem(jsCoverJS)).endsWith("\njscoverage_isReport = true;");
}

@Test
public void shouldNotCopyExtraFiles() throws IOException {
ioUtils.copy(data1, new File(reportDir1, "dummy.html"));
Main.main(args);
assertThat(new File(reportDir12, "dummy.html").exists(), is(false));
assertThat(new File(reportDir12, "dummy.html").exists()).isFalse();
}

@Test
public void shouldMergeDataWithoutSource() throws IOException {
String expected = ioUtils.loadFromClassPath("/jscover/report/jscoverage-select-1-3.json");
Main.main(args);
String merged = ioUtils.loadFromFileSystem(new File(reportDir12, "jscoverage.json"));
assertThat(merged, equalTo(expected));
assertThat(merged).isEqualTo(expected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,7 @@ You should also get your employer (if you work as a programmer) or your
import java.net.ServerSocket;
import java.net.Socket;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;

//Provided by https://github.com/devangnegandhi 6 Sept 2013
Expand Down Expand Up @@ -439,12 +438,12 @@ public void shouldIncludeUnloadJSInSavedReport() throws Exception {
webClient.waitForBackgroundJavaScript(2000);
String result = page.getElementById("storeDiv").getTextContent();

assertThat(result, containsString("Coverage data stored at " + new File(reportDir).getPath()));
assertThat(result).contains("Coverage data stored at " + new File(reportDir).getPath());

String json = ioUtils.toString(jsonFile);
assertThat(json, not(containsString("/root.js")));
assertThat(json, containsString("/level1/level1.js"));
assertThat(json, containsString("/level1/level2/level2.js"));
assertThat(json).doesNotContain("/root.js");
assertThat(json).contains("/level1/level1.js");
assertThat(json).contains("/level1/level2/level2.js");

String url = "file:///" + new File(reportDir + "/jscoverage.html").getAbsolutePath();
page = webClient.getPage(url);
Expand All @@ -458,9 +457,9 @@ public void shouldIncludeUnloadJSInSavedReport() throws Exception {
}

private void verifyCoverage(HtmlPage page, String uri, String linePercentage, String branchPercentage, String functionPercentage) {
assertThat(getHtmlElement(page, "//tr[@id='row-" + uri + "']/td[11]/span").getTextContent(), equalTo(linePercentage));
assertThat(getHtmlElement(page, "//tr[@id='row-" + uri + "']/td[12]/span").getTextContent(), equalTo(branchPercentage));
assertThat(getHtmlElement(page, "//tr[@id='row-" + uri + "']/td[13]/span").getTextContent(), equalTo(functionPercentage));
assertThat(getHtmlElement(page, "//tr[@id='row-" + uri + "']/td[11]/span").getTextContent()).isEqualTo(linePercentage);
assertThat(getHtmlElement(page, "//tr[@id='row-" + uri + "']/td[12]/span").getTextContent()).isEqualTo(branchPercentage);
assertThat(getHtmlElement(page, "//tr[@id='row-" + uri + "']/td[13]/span").getTextContent()).isEqualTo(functionPercentage);
}

private HtmlElement getHtmlElement(HtmlPage page, String xpathExpr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

import java.io.File;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;

public abstract class HtmlServerUnloadedJSTestBaseClass {
Expand Down Expand Up @@ -50,11 +48,11 @@ public void shouldIncludeUnloadJSInSavedReport() throws Exception {
webClient.waitForBackgroundJavaScript(2000);
String result = page.getElementById("storeDiv").getTextContent();

assertThat(result, containsString("Coverage data stored at " + new File(getReportDir()).getPath()));
assertThat(result).contains("Coverage data stored at " + new File(getReportDir()).getPath());

String json = ioUtils.toString(jsonFile);
assertThat(json, containsString("/root.js"));
assertThat(json, containsString("/level1/level2/level2.js"));
assertThat(json).contains("/root.js");
assertThat(json).contains("/level1/level2/level2.js");

String url = "file:///" + new File(getReportDir() + "/jscoverage.html").getAbsolutePath();
page = webClient.getPage(url);
Expand All @@ -68,9 +66,9 @@ public void shouldIncludeUnloadJSInSavedReport() throws Exception {
}

private void verifyCoverage(HtmlPage page, String uri, String linePercentage, String branchPercentage, String functionPercentage) {
assertThat(getHtmlElement(page, "//tr[@id='row-" + uri + "']/td[11]/span").getTextContent(), equalTo(linePercentage));
assertThat(getHtmlElement(page, "//tr[@id='row-" + uri + "']/td[12]/span").getTextContent(), equalTo(branchPercentage));
assertThat(getHtmlElement(page, "//tr[@id='row-" + uri + "']/td[13]/span").getTextContent(), equalTo(functionPercentage));
assertThat(getHtmlElement(page, "//tr[@id='row-" + uri + "']/td[11]/span").getTextContent()).isEqualTo(linePercentage);
assertThat(getHtmlElement(page, "//tr[@id='row-" + uri + "']/td[12]/span").getTextContent()).isEqualTo(branchPercentage);
assertThat(getHtmlElement(page, "//tr[@id='row-" + uri + "']/td[13]/span").getTextContent()).isEqualTo(functionPercentage);
}

private HtmlElement getHtmlElement(HtmlPage page, String xpathExpr) {
Expand Down
12 changes: 5 additions & 7 deletions src/test-acceptance/java/jscover/server/HtmlUnitJSTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,7 @@ You should also get your employer (if you work as a programmer) or your

import java.util.List;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.startsWith;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class HtmlUnitJSTest {
Expand Down Expand Up @@ -392,10 +390,10 @@ public void shouldTestJavaScript() throws Exception {
//Verify Jasmine test result
HtmlPage frame = (HtmlPage)page.getFrameByName("browserIframe").getEnclosedPage();
List<HtmlSpan> passed = frame.getByXPath("//span[contains(@class,'jasmine-passed')]");
assertThat(passed.size(), equalTo(1));
assertThat(frame.getByXPath("//span[contains(@class,'jasmine-failed')]").size(), equalTo(0));
assertThat(frame.getByXPath("//span[contains(@class,'jasmine-skipped')]").size(), equalTo(0));
assertThat(passed.get(0).asNormalizedText(), startsWith("15 specs, 0 failures"));
assertThat(passed.size()).isEqualTo(1);
assertThat(frame.getByXPath("//span[contains(@class,'jasmine-failed')]").size()).isEqualTo(0);
assertThat(frame.getByXPath("//span[contains(@class,'jasmine-skipped')]").size()).isEqualTo(0);
assertThat(passed.get(0).asNormalizedText()).startsWith("15 specs, 0 failures");

//Store Report
frame.executeJavaScript("jscoverage_report();");
Expand Down
Loading
Loading