Forum Stats

  • 3,826,780 Users
  • 2,260,707 Discussions
  • 7,897,072 Comments

Discussions

C:....Local\NetBeans\Cache\8.2\executor-snippets\run.xml:48

User_AYF65
User_AYF65 Member Posts: 135 Red Ribbon
edited Oct 7, 2018 11:45AM in New To Java

Hi,
I am getting executor-snippets\run.xml:48 error. I have a main class "JavaJUNITExample8_2". I have created a PrintGrades2 class in it.

public class PrintGrades2 {          static char getGrade(int score) {        char grade='\0';        if (score >= 90)             grade='A';            else if(score>=80)                grade = 'B';                    :            and so on                    :            return grade;              }

And i created a test class using Tools->create/update test.

import org.junit.After;import org.junit.AfterClass;import org.junit.Before;import org.junit.BeforeClass;import org.junit.Test;import static org.junit.Assert.*;/** * * @author HP */public class PrintGrades2Test {        public PrintGrades2Test() {    }        @BeforeClass    public static void setUpClass() {    }        @AfterClass    public static void tearDownClass() {    }        @Before    public void setUp() {    }        @After    public void tearDown() {    }    /**     * Test of getGrade method, of class PrintGrades2.     */    @Test    public void testGetGrade() {        System.out.println("getGrade");        System.out.println("getGrade");        int score = 0;        char expResult = ' ';        assertTrue('A'==PrintGrades2.getGrade(95));      :     :    and so on:                    }    }



and my main method of main class is:

package javajunitexample8_2;import org.junit.runner.JUnitCore;import org.junit.runner.Result;import org.junit.runner.notification.Failure;/** * * @author HP */public class JavaJUNITExample8_2 {    /**     * @param args the command line arguments     */    public static void main(String[] args) {        // TODO code application logic here        Result result = JUnitCore.runClasses(PrintGrades2Test.class); //error on this linefor (Failure failure : result.getFailures()) {         System.out.println(failure.toString());      }      System.out.println("Result=="+result.wasSuccessful());            }    }

I am getting following error message:

C:........\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:48: Cancelled by user.BUILD FAILED (total time: 3 seconds)

And code of run.xml is:

<?xml version="1.0" encoding="UTF-8"?><!--DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.Copyright 2010 Oracle and/or its affiliates. All rights reserved.Oracle and Java are registered trademarks of Oracle and/or its affiliates.Other names may be trademarks of their respective owners.The contents of this file are subject to the terms of either the GNUGeneral Public License Version 2 only ("GPL") or the CommonDevelopment and Distribution License("CDDL") (collectively, the"License"). You may not use this file except in compliance with theLicense. You can obtain a copy of the License athttp://www.netbeans.org/cddl-gplv2.htmlor nbbuild/licenses/CDDL-GPL-2-CP. See the License for thespecific language governing permissions and limitations under theLicense.  When distributing the software, include this License HeaderNotice in each file and include the License file atnbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates thisparticular file as subject to the "Classpath" exception as providedby Oracle in the GPL Version 2 section of the License file thataccompanied this code. If applicable, add the following below theLicense Header, with the fields enclosed by brackets [] replaced byyour own identifying information:"Portions Copyrighted [year] [name of copyright owner]"Contributor(s):The Original Software is NetBeans. The Initial Developer of the OriginalSoftware is Sun Microsystems, Inc. Portions Copyright 2008 SunMicrosystems, Inc. All Rights Reserved.If you wish your version of this file to be governed by only the CDDLor only the GPL Version 2, indicate your decision by adding"[Contributor] elects to include this software in this distributionunder the [CDDL or GPL Version 2] license." If you do not indicate asingle choice of license, a recipient has the option to distributeyour version of this file under either the CDDL, the GPL Version 2 orto extend the choice of license to its licensees as provided above.However, if you add GPL Version 2 code and therefore, elected the GPLVersion 2 license, then the option applies only if the new code ismade subject to such option by the copyright holder.--><project name="{0} (run)" default="run" basedir=".">    <target name="run">                <translate-classpath classpath="${classpath}" targetProperty="classpath-translated" />        <property name="run.jvmargs" value="" />        <property name="work.dir" value="${basedir}"/>        <property name="application.args" value="" />        <property name="java.failonerror" value="true"/>        <java classpath="${classpath-translated}" classname="${classname}" dir="${work.dir}" jvm="${platform.java}" fork="true" failonerror="${java.failonerror}">            <jvmarg value="-Dfile.encoding=${encoding}"/>            <redirector inputencoding="${encoding}" outputencoding="${encoding}" errorencoding="${encoding}"/>            <jvmarg line="${run.jvmargs}" />            <arg line="${application.args}" />            <syspropertyset>                <propertyref prefix="run-sys-prop."/>                <mapper from="run-sys-prop.*" to="*" type="glob"/>            </syspropertyset>        </java>    </target></project>

Some body please guide me.

Zulfi.

Comments

  • User_AYF65
    User_AYF65 Member Posts: 135 Red Ribbon
    edited Oct 6, 2018 7:38PM

    Hi,

    I am getting a compilation error also at:

    Result result = JUnitCore.runClasses(PrintGrades2Test.class);

    I am using NetBeans 8.2 and I am working on Windows 10.

    Zulfi.

    == (Afterwards)

    Right now I have put all my files in:

    D:......\JavaJUNITExample8_2\src\javajunitexample8_2

    I am getting any compilation error but exception

    Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: <any>

    at javajunitexample8_2.JavaJUNITExample8_2.main(JavaJUNITExample8_2.java:23)

    C:\Users\HP\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1

    BUILD FAILED (total time: 2 seconds)

    Please guide me how to solve this problem

    Zulfi.

  • User_AYF65
    User_AYF65 Member Posts: 135 Red Ribbon
    edited Oct 7, 2018 10:50AM

    Hi,

    I have solved this prob. I have put all files (test file & the file to test alsong with main class file) in folder: i.e. in

    JavaJUNITExample8_2\src\javajunitexample8_2

    & then put the same package name as in my main class (i.e the public class having main method, & then I moved the jar files from test folder (i.e Junit**.jar & hamcrest.jar into my Lib folder.Zulfi.
  • Unknown
    edited Oct 7, 2018 11:45AM

    Then please mark the thread ANSWERED.