Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6993035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:42:46+00:00 2026-05-27T19:42:46+00:00

I have a test class, all the tests of this class runs fine if

  • 0

I have a test class, all the tests of this class runs fine if I run in eclipse. (right click on the file , run as jUnit) but when I am trying to run using Ant Script it fails.

Actually this test is to be run against 2 browsers. This test runs fine against IE Chrome. It runs fine against IE. But test is not able to run against Chrome. I am not sure what’s happening.
All the driver related information I have placed under allresources/drivers/ of the project path. And browser profiles i have kept under browserProfiles folder of the project.

I am not sure why tests are not able to be picked up for Chrome.

I have attached test code and the code where I am trying to create webdriver and seldriver in the source code.

package com.mytests;

public class MyParamTest {
private MyWrapperForBrowser browser;

@Before
public void setup(){
    b = new MyWrapperForBrowser("chrome");
    b.start();
}

@Test
public void testCURDOnEntity() {
    MyEntity e = new MyEntity(browser);
    Assert.assertTrue(e.createMessage("message", "text"));
    // more business logic..
}
}

And source code

    package com.mysrc;

import java.util.*;
import org.openqa.selenium.*;

public class MyWrapperForBrowser {

    private final WebDriver webDriver;
    private WebDriverBackedSelenium selDriver;


public MyWrapperForBrowser(String driver) {
        if (driver.equalsIgnoreCase("IE")
        {
            // create webDriver , selDriver
        }
        else{

       System.setProperty("webdriver.chrome.driver",
                    "allresources/drivers/chromedriver.exe");
        DesiredCapabilities broserCapabilities = DesiredCapabilities.chrome();
        broserCapabilities.setCapability("chrome.switches", Arrays.asList("--start-minimized"));
        String url = this.getClass().getClassLoader().getResource("browserProfiles/ChromeProfile").getPath()
                .substring(1);
        broserCapabilities.setCapability("chrome.switches",
                Arrays.asList("--user-data-dir=" + url));
        webDriver = new ChromeDriver(broserCapabilities);
        selDriver = new WebDriverBackedSelenium(webDriver, "");
}
}

public void start() {
    webDriver.get(getURL());
    selDriver.windowMaximize();
 }
 }

The stack trace which I am getting while running the ANT build is :

[junit] java.util.zip.ZipException: error in opening zip file
[junit]     at java.util.zip.ZipFile.open(Native Method)
[junit]     at java.util.zip.ZipFile.<init>(ZipFile.java:114)
[junit]     at java.util.zip.ZipFile.<init>(ZipFile.java:131)
[junit]     at org.apache.tools.ant.AntClassLoader.getResourceURL(AntClassLoader.java:1028)
[junit]     at org.apache.tools.ant.AntClassLoader$ResourceEnumeration.findNextResource(AntClassLoader.java:147)
[junit]     at org.apache.tools.ant.AntClassLoader$ResourceEnumeration.<init>

Here is the build script :

<project name="MyProject" default="build-proj" basedir=".">

    <property file="./build.properties" />

    <path id="project.classpath">   
        <fileset dir="resources/drivers">
            <include name="*.*" />
        </fileset>       
    </path>

    <taskdef resource="emma_ant.properties">
        <classpath>
            <pathelement path="${lib.dir}/emma_ant-2.1.5320.jar" />
            <pathelement path="${lib.dir}/emma-2.1.5320.jar" />
        </classpath>
    </taskdef>

    <target name="build-proj">
        <antcall target="cleanup" />
        <antcall target="compile" />
        <antcall target="test" />
    </target>

    <target name="cleanup" description="clean up">
        <delete dir="${build.dir}" />
        <delete dir="${dist.dir}" />
        <delete dir="${test.report.dir}" />
        <mkdir dir="${build.dir}" />
        <mkdir dir="${build.src.dir}" />
        <mkdir dir="${build.test.dir}" />
    </target>

    <target name="compile" description="compiling all the code">
        <javac srcdir="${src.dir}" destdir="${build.src.dir}" debug="true">
            <classpath>
                <path refid="project.classpath" />
            </classpath>
        </javac>
        <javac srcdir="${test.dir}" destdir="${build.test.dir}" debug="true">
            <classpath>
                <path refid="project.classpath" />
                <path path="${build.src.dir}" />
            </classpath>
        </javac>
    </target>

    <target name="test">
        <junit haltonfailure="false" printsummary="true" fork="true" forkmode="once" >
            <classpath>
                <pathelement path="${src.dir}" />
                <pathelement path="${build.src.dir}" />
                <pathelement path="${build.test.dir}" />
                <pathelement path="${test.data.dir}" />
                <path refid="project.classpath" />
            </classpath>

            <formatter type="xml"/>
            <batchtest todir="${test.report.dir}">
                <fileset dir="${build.test.dir}">
                    <include name="**/*Test.class" />
                </fileset>
            </batchtest>
        </junit>
    </target>
</project>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:42:46+00:00Added an answer on May 27, 2026 at 7:42 pm

    Probably your classpath contains not only .jar files.

    The ant task “junit” only likes .jar files (or let’s better say Path like structure, to use an Ant term) in the classpath element.

    You could try to use

    <include name="*.jar" />
    

    instead of

    <include name="*.*" />
    

    in your “project.classpath”-fileset.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Test Class, that test the access of all page with different
I have some test class TestKlass = (function() { function TestKlass(value) { this.value =
say I have: class Test { public static int Hello = 5; } This
I have a JUnit test class in which I have several static final int
I have a test sample about coherence lock-unlock mechanism like this: public class Test
I want to run Junit test suites that contain various test classes. Of all
I have three JUnit test classes that all had some common code, including identical
I have been having some problems with the test debugger in VS10. All tests
Ok, I have an Nunit test class setup that runs though a method, lets
I have a unit tests that overrides a base test class. The test setups

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.