Skip to content

Junit starts from a different location  #94

Closed

Description

Hello fellows,

in a project with several files an including some integration tests, I am trying to perform the following actions:

File csFile = new File("src/test/resources/Program.cs").getAbsoluteFile();

Let's say that my project is in C:\temp\myproject therefore i will expect to get something like:

C:\temp\myproject\src\test\resources\Program.cs

but instead i got:

Caused by: java.nio.file.NoSuchFileException: C:\Program Files\Microsoft VS Code\src\test\resources
	at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
	at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:90)
	at sun.nio.fs.WindowsLinkSupport.getRealPath(WindowsLinkSupport.java:259)
	at sun.nio.fs.WindowsPath.toRealPath(WindowsPath.java:836)
	at sun.nio.fs.WindowsPath.toRealPath(WindowsPath.java:44)
	at org.sonar.api.batch.fs.internal.DefaultInputModule.initBaseDir(DefaultInputModule.java:86)
	... 27 more

Is possible to setup the start folder for Junit?

Activity

  1. ansyral commented on Jan 22, 2018

    @ansyral
    Collaborator

    Cristian Andres (@bootrider) one way to solve this might be a test configuration where you could configure your working folder. We plan to support this later. What do you think about this? BTW, right now you could use getClass().getClassLoader().getResource() to walkaround if it is ok to update the code.

  2. nazneen84 commented on Feb 23, 2018

    @nazneen84

    Xuan Zhou (@ansyral) Is this the right issue to track to allow JUnit tests run from a configured location?

  3. ansyral commented on Feb 26, 2018

    @ansyral
    Collaborator

    let's use #100 to track this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions