Home > OS >  No class Main class found . Smoke testing
No class Main class found . Smoke testing

Time:02-01

I did the application and it said that there was no main.java. Is there any I can fix this?

package test.cases.business;

import model.business.Customer;

public class CustomerTest {

    //=======================================
    //Smoke Tests - Construction

    /** Conduct a smoke test for the construction of
     * a Customer with no args
     */
    public void test_newInstance() {
        prn("\n-- test_newInstance --");
        Customer cust = Customer.newInstance();
        prn(cust.toString());
    }

    /** Conduct a smoke test for the construction of
     * a Customer with passed name and phone
     */
    public void test_fromFirstLastPhone() {
        prn("\n-- test_fromFirstLastPhone --");
        Customer cust;
        cust = Customer.fromFirstLastPhone("Asha", "Gupta", "1112223333");
        prn(cust.toString());
    }

    //=======================================
    //Helpers

    public void prn(Object o) {
        System.out.println(o);
    }

    //=======================================
    //Main

    public static void main(String[] args) {
        CustomerTest test = new CustomerTest();
        test.test_newInstance();
        test.test_fromFirstLastPhone();
    }

}

CodePudding user response:

You do not need main.java. However if what you posted is your java source code, be sure to compile it, then make the necessary class available to Java when running it.

You can run your code like so given that Java is able to find your CustomerTest.java. It should reside underneath test/cases/business (relative to the working directory) and be called CustomerTest.class.

java test.cases.business.CustomerTest

If the class resides elsewhere, you will need to point Java to the directory or ZIP/JAR file hosting that class in the same folder stucture like so:

java -cp <path to basedir> test.cases.business.CustomerTest

I am not sure how you develop and run your stuff. An IDE might make your life easier. You might want to get started with the Oracle Java tutorial.

CodePudding user response:

enter image description here

This is where I save my file. How do I add java test.cases.business.CustomerTest?

  •  Tags:  
  • Related