0
votes
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object

This is the error I received while running the test Case.

This is the file.

package com.shanu.shopbackend.test;

import static org.junit.Assert.assertEquals;

import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import com.shanu.shopbackend.dao.CategoryDAO;
import com.shanu.shopbackend.dto.Category;

public class CategoryTestCases {

    private static AnnotationConfigApplicationContext context;
    private static CategoryDAO categoryDAO;
    private Category category;


    @BeforeClass
    public static void init(){
        context = new AnnotationConfigApplicationContext();
        context.scan("com.shanu.shopbackend");
        context.refresh();

        categoryDAO= (CategoryDAO)context.getBean("categoryDAO");
    }

    @Test
    public void testAddCategory() {
        category = new Category();
        category.setName("Test Mobile");
        category.setDescription("Mobile Descp");
        category.setImageURL("CAT_2.png");
        assertEquals("Succesfully Added a Category",true,categoryDAO.add(category));

    }
}

For Certain Test Case, I found that Environment Variable setting is null.

Junit Test Case

1

1 Answers

0
votes

That error suggests that there is a problem with your Java installation, or at least Eclipse is unable to find it.

You could try adding this to your eclipse.ini file. Be sure to update the path to point to your actual Java installation.

-vm
C:\Java\JDK\1.8\bin\javaw.exe

Source: https://wiki.eclipse.org/Eclipse.ini#-vm_value:_Windows_Example