'Eclipse TestNG java.lang.AssertionError

My code works, TestNG works, I got results as expected, but this error appears at the end of TestNG results:

Error screenshot

Error code:

java.lang.AssertionError: Couldn't find resource: jquery.min.js
at org.testng.reporters.jq.Main.generateReport(Main.java:92)
at org.testng.TestNG.generateReports(TestNG.java:1093)
at org.testng.TestNG.run(TestNG.java:1036)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

I tried to fix this by removing Assertion from my project, even import of package, but an error still appears...

Here is my code of the script:

package myWork;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.testng.Assert;
import org.testng.annotations.Test;

public class Demo {

@Test
public void regular() {
    // TODO Auto-generated method stub

    ArrayList<String> names = new ArrayList();
    names.add("APrvi");
    names.add("Drugi");
    names.add("ATreci");
    names.add("Cetvrti");
    names.add("Apeti");
    
    Long res = names.stream().filter(s->s.startsWith("A")).count();
    
    System.out.println(res);
    
    names.stream().filter(s->s.length()>5).forEach(s->System.out.println(s));
    
    names.stream().filter(s->s.length()>5).limit(1).forEach(s->System.out.println(s));
    
}

@Test
public void StreamMap() {
    
    Stream.of("APrvitest1", "DrugiA", "ATrecitest", "ACetr", "EtcA").
    filter(s->s.endsWith("A")).
    map(s->s.toUpperCase()).
    forEach(s->System.out.println(s));
    
    ArrayList<String> names = new ArrayList();
    names.add("PrvaLista");
    names.add("DrugaLista");
    names.add("ATrecaLista");
    names.add("ACetr");
    names.add("ApetaLista");
    
    List<String> names1 = Arrays.asList("AzPrvitest1", "DrugiA", "ATrecitest", "ACetr", "EtcA");
    names.stream().filter(s->s.startsWith("A")).sorted().map(s->s.toUpperCase()).forEach(s->System.out.println(s));
    
    Stream<String> newStream = Stream.concat(names.stream(), names1.stream());
    
    //Merge two lists
    //newStream.sorted().forEach(s->System.out.println(s));
    
    boolean flag = newStream.anyMatch(s->s.equalsIgnoreCase("ApetaLista"));
    
    Assert.assertTrue(flag);
    
}

@Test
public void StreamCollect() {
    
    List<String> ls = Stream.of("APrvitest1", "DrugiA", "ATrecitest", "ACetr", "EtcA").
    filter(s->s.endsWith("A")).
    map(s->s.toUpperCase()).collect(Collectors.toList());
    
    System.out.println(ls.get(0));
    
    List<Integer> values = Arrays.asList(3, 2, 2, 7, 5, 1, 9, 7);
    
    //print unique number from this array
    //sort the array
    
    values.stream().distinct().forEach(s->System.out.println(s));
    List<Integer> li = values.stream().distinct().sorted().collect(Collectors.toList());
    
    System.out.println("3rd number is: " + li.get(2));
    
}

}

And this is the output of the results:

    [RemoteTestNG] detected TestNG version 7.4.0
    DRUGIA
    3
    2
    7
    5
    1
    9
    3rd number is: 3
    DRUGIA
    ETCA
    ACETR
    ATRECALISTA
    APETALISTA
    3
    ATreci
    Cetvrti
    ATreci
    PASSED: regular
    PASSED: StreamCollect
    PASSED: StreamMap
    
    ===============================================
        Default test
        Tests run: 3, Failures: 0, Skips: 0
    ===============================================
    
    
    ===============================================
    Default suite
    Total tests run: 3, Passes: 3, Failures: 0, Skips: 0
    ===============================================
    
    java.lang.AssertionError: Couldn't find resource: jquery.min.js
        at org.testng.reporters.jq.Main.generateReport(Main.java:92)
        at org.testng.TestNG.generateReports(TestNG.java:1093)
        at org.testng.TestNG.run(TestNG.java:1036)
        at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
        at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
        at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)


Solution 1:[1]

As of TestNG 7.4.0 the below resources loading viz.,

  1. jquery.js
  2. jquery.min.*

was streamlined when we fixed https://github.com/cbeust/testng/issues/2406

Please check your CLASSPATH and ensure that you have at-least https://mvnrepository.com/artifact/org.webjars/jquery/3.5.1

The error is basically indicating that your class path is messed up owing to which TestNG is not able to load jquery.js via the web jars dependency.

Solution 2:[2]

I was facing same problem. I was using 7.x then I changed to 6.14.3.

steps

  1. Go to eclipse( I am using Version: 2021-03 (4.19.0))

  2. Help>install new software> add

  3. Give name=TestNG Location=https://testng.org/testng-eclipse-update-site and in details untick show only the latest versions of available software.

  4. Now it will show the list with versions

  5. Select Guava: Google Core Libraries for Java 15.0.0.v201403281430

    TestNG 6.14.3.201902250526

    TestNG P2 Feature 6.14.3.r201802240500

    TestNG M2E (Maven) Integration (Optional) 6.14.3.201902250526

Solution 3:[3]

Well, I just changed the TestNG version from 7.4.0 to 6.14.3 and the error disappeared

Solution 4:[4]

Yes same here. I was using the latest one. Then I changed to 6.14.3 and it worked.

Solution 5:[5]

To fix this issue please follow this 3 step:-

  1. Delete the .classpath file from the project root directory.
  2. Right click on project & do maven-->update project.
  3. Then the fresh .classpath file will created.

Now run the test. the issue will be fixed.

Solution 6:[6]

Just download jquery-3.5.1.jar and add build path with external Jar.it will work

Solution 7:[7]

Just update the testNG plugin

  1. if you are using eclipse and goto marketplace and check for updates it will show you testNG to update once you update and restart the eclipse this will resolve the issue.

Solution 8:[8]

If you are using Maven project, add the following dependency to the pom.xml file under dependencies:

https://mvnrepository.com/artifact/org.webjars/jquery/3.5.1

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Krishnan Mahadevan
Solution 2 bad_coder
Solution 3 worldhost_null
Solution 4 sharful
Solution 5 Victor
Solution 6 Hanumanth
Solution 7 pravi
Solution 8 fatih