microsoft / vscode-java-test

Run and debug Java test cases in Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-test
Other
292 stars 125 forks source link

Test runner showing "Configure Python Tests" instead of Java #1646

Open KaziAfrozAlam opened 8 months ago

KaziAfrozAlam commented 8 months ago

image

KaziAfrozAlam commented 8 months ago

I get this issue after mannually downloading of junit also

jdneo commented 8 months ago

This means the Java project is not recognized.

How does your java project look like? Would you mind sharing it?

KaziAfrozAlam commented 8 months ago

image

jdneo commented 8 months ago
Screenshot 2024-01-04 at 09 48 13

This icon indicates that the extension failed to activate.

Is there any error in the logs? https://github.com/redhat-developer/vscode-java/wiki/Troubleshooting#get-the-java-language-servers-workspace-logs

KaziAfrozAlam commented 8 months ago

image

Now also it was not working

jdneo commented 8 months ago

Would you mind sharing your project if possible?

KaziAfrozAlam commented 8 months ago

Does I have to share the full project from the first?

jdneo commented 8 months ago

Just a minimal project which can repro your issue will be fine.

KaziAfrozAlam commented 8 months ago

`

package com.bts.controller;

import java.time.LocalDate; import org.junit.Test; import com.bts.beans.Project; import com.bts.beans.enums.ProjectStatus; import com.bts.beans.enums.UserType; import com.bts.exceptions.AuthorizationException; import com.bts.exceptions.BugAssignmentException; import com.bts.exceptions.DataAccessException; import com.bts.exceptions.InvalidDataException; import com.bts.exceptions.InvalidDateException; import com.bts.exceptions.ProjectManagerLimitExceededException; import com.bts.service.BugService; import com.bts.service.ProjectService; import com.bts.service.TeamService; import com.bts.service.UserService; import com.bts.util.ObjectFactory;

public class TestCases { static UserService userService = ObjectFactory.getUserInstance(); static ProjectService projectService = ObjectFactory.getProjectServiceInstace(); static BugService bugService = ObjectFactory.getBugServiceInstance(); static TeamService teamService = ObjectFactory.getTeamServiceInstance();

public static void main(String[] args) {
    testUserRegistration();
    testCreateNewProject();
}
@Test
private static void testUserRegistration() {
    System.out.println("Testing User Registration...");

    // Test case a: All fields are mandatory
    try{
        userService.registerUser("alex@alex.com", null, null);
        System.err.println("Test case 1a: Failed");
    }
    catch (Exception e) {System.out.println("Test case 1a: Passed");
    }

    // Test case b: Email should exist and match with the role
    try{
        userService.registerUser("alex@alex.com", "Alex@123", UserType.DEVELOPER);
        System.err.println("Test case 1b: Failed");
    }
    catch(Exception e) {
        System.out.println("Test case 1b: Passed");
    }

    // Test case c: User should not have already been registered
    try{
        userService.registerUser("max@champ.com", "Max@123", UserType.PROJECTMANAGER);
        System.err.println("Test case 1c: Failed");
    }
    catch(Exception e) {
        System.out.println("Test case 1c: Passed");
    }
}
@Test
private static void testCreateNewProject() {
    int projectManagerId;
    String projectName;
    String description;
    LocalDate startDate;
    ProjectStatus status;
    int testerId;
    int developerId;
    // Test case 2a: Start date should be at least 2 days later than the current date
    projectManagerId = 1;
    projectName = "Something";
    description = "Something";
    startDate = LocalDate.parse("2023-09-15");
    status = ProjectStatus.INPROGRESS;
    testerId = 2;
    try {
        projectService.createProject(new Project(projectManagerId, projectName, description,startDate, status), projectManagerId, testerId);
        System.err.println("Test case 2a: Failed");
    } catch (DataAccessException | ProjectManagerLimitExceededException | InvalidDateException
            | InvalidDataException e) {
        System.out.println("Test case 2a: Passed");
    }
    // Test case 2b: Project status should be set to "in progress"
    startDate = LocalDate.parse("2023-09-25");
    status = ProjectStatus.COMPLETED;
    try {
        projectService.createProject(new Project(projectManagerId, projectName, description,startDate, status), projectManagerId, testerId);
        System.err.println("Test case 2b: Failed");
    } catch (DataAccessException | ProjectManagerLimitExceededException | InvalidDateException
            | InvalidDataException e) {
        System.out.println("Test case 2b: Passed");
    }
    // Test case 2c: Developers can be assigned to only one project
    developerId = 3;
    try {
        bugService.assignBugToDeveloper(projectManagerId, developerId);
        System.err.println("Test case 2c: Failed");
    } catch (BugAssignmentException | DataAccessException | AuthorizationException e) {
        System.out.println("Test case 2c: Passed");
    }

    // Test case 2d: Testers can be assigned to a maximum of 2 projects
    testerId = 4;
    try {
        projectService.createProject(new Project(projectManagerId, projectName, description,startDate, status), projectManagerId, testerId);
        System.err.println("Test case 2d: Failed");
    } catch (DataAccessException | ProjectManagerLimitExceededException | InvalidDateException
            | InvalidDataException e) {
        System.out.println("Test case 2d: Passed");
    }

    // Test case 2e: Testers can be assigned to projects only under same project manager
    testerId = 5;
    try {
        projectService.createProject(new Project(projectManagerId, projectName, description,startDate, status), projectManagerId, testerId);
        System.err.println("Test case 2e: Failed");
    } catch (DataAccessException | ProjectManagerLimitExceededException | InvalidDateException
            | InvalidDataException e) {
        System.out.println("Test case 2e: Passed");
    }

}

}`

KaziAfrozAlam commented 8 months ago

https://1drv.ms/f/s!An-s8mCZusGNgeYNgyjTVEjqH1MJrw?e=JbFvBY

This is my full project source code link, you can check from here and you can find the code file from com/bts/controller/testcases.java

jdneo commented 8 months ago

Ok, I open the folder onlinebugtrackingsystem. Since it contains .classpath and .project files. It will be treated as Eclipse project. (which means the setting java.project.sourcePaths, java.project.outputPath & java.project.referencedLibraries) won't work for them.

If you need to edit your project classpath, you can open .classpath file and add them there. Like what you did for the mysql-connector-j-8.0.33.jar.

KaziAfrozAlam commented 8 months ago

I add the path and go this window but when i run the code the import of org.junit.Test error is shown image

KaziAfrozAlam commented 7 months ago

Again this error came, what should I do