Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jdt-dev] Checking if a class is from a test package

Thanks all,

Mickael suggestion actuall worked for me.

Br,
Gayan.

On Fri, Apr 3, 2020 at 3:12 PM Gayan Perera <gayanper@xxxxxxxxx> wrote:
Hi daniel,

My requirment is to check if my project class file is a test class file or a production class file. So i can my test only codemining provider on those classes. 

Br,
Gayan

On Fri, 3 Apr 2020 at 15:10, Daniel Megert <daniel_megert@xxxxxxxxxx> wrote:
Another thing you could do is to test for JUnit being on the class path.

Dani



From:        "Sarika Sinha" <sarika.sinha@xxxxxxxxxx>
To:        jdt-dev@xxxxxxxxxxx
Date:        03.04.2020 14:29
Subject:        [EXTERNAL] Re: [jdt-dev] Checking if a class is from a test package
Sent by:        jdt-dev-bounces@xxxxxxxxxxx




If Java Build Path "Source folder" is set to "Contains test Sources", this property can also be used to identify.
 
Thanks & Regards,
Sarika
 
----- Original message -----
From: Mickael Istria <mistria@xxxxxxxxxx>
Sent by: jdt-dev-bounces@xxxxxxxxxxx
To: "Eclipse JDT general developers list." <jdt-dev@xxxxxxxxxxx>
Cc:
Subject: Re: [jdt-dev] Checking if a class is from a test package
Date: Fri, Apr 3, 2020 5:37 PM
 

 
 
On Fri, Apr 3, 2020 at 12:45 PM Gayan Perera <gayanper@xxxxxxxxx> wrote:
How to check a given class is in side test source folder or production source folder.
 
Something like:
 
Arrays.stream(((IPackageFragmentRoot)javaProject.findElement(folder.getPath()).getParent()).getRawClasspathEntry().getExtraAttributes()).anyMatch(att -> "test".equals(att.getName()) && Boolean.parseBoolean(att.getValue()))
might work.
 
HTH
_______________________________________________
jdt-dev mailing list
jdt-dev@xxxxxxxxxxx
To unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jdt-dev
 
_______________________________________________
jdt-dev mailing list
jdt-dev@xxxxxxxxxxx
To unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jdt-dev



_______________________________________________
jdt-dev mailing list
jdt-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jdt-dev

Back to the top