Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 332602 - [testsources][JUnit] Create new JUnit test case in test folder
Summary: [testsources][JUnit] Create new JUnit test case in test folder
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P5 enhancement (vote)
Target Milestone: 4.8 M5   Edit
Assignee: Till Brychcy CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 49611 77980 400980 529944 (view as bug list)
Depends on: 224708
Blocks:
  Show dependency tree
 
Reported: 2010-12-15 04:00 EST by Bartosz Radaczyński CLA
Modified: 2018-02-19 11:03 EST (History)
9 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bartosz Radaczyński CLA 2010-12-15 04:00:16 EST
Build Identifier: 20100218-1602

When creating a new junit test case, the test case gets created by default in the appropriate subdirectory of /src/main. I would like that to be a subdir of /src/test instead. 

Perhaps consider choosing the destination folder with "test" in the name as the suggestion, or remember the last directory that the user put in...

Reproducible: Always

Steps to Reproduce:
create a new Junit test case.
Comment 1 Dani Megert CLA 2011-01-03 07:04:36 EST
> Perhaps consider choosing the destination folder with "test" in the name as the
> suggestion, or remember the last directory that the user put in...
We don't want to add hidden smartness based on the name. Using the last recently used would have been an option at the beginning but changing it now would be too surprising for existing users. Once bug 224708 is fixed we would use the test folder.
Comment 2 Dani Megert CLA 2013-02-18 04:16:49 EST
Or we could look for a folder that we recognize as having test classes.
Comment 3 Dani Megert CLA 2013-02-18 04:17:04 EST
*** Bug 400980 has been marked as a duplicate of this bug. ***
Comment 4 Oliver Pfeiffer CLA 2013-11-29 05:24:17 EST
Just wanted to open a new bug for the issue, but glad I found this one before, so I want to vote for it...

I doubt to consider this as hidden smartness, at least not for maven based projects where in the default layout src/test IS the folder for test code (if not overridden in the pom). Quite the contrary, I (and likely also other existing users) find it surprising that my test cases get placed under src/main by Eclipse every time I create one - it's not the behaviour you would expect (again, for maven based projects) and more than once took me hours to diagnose errors caused by it.
Comment 5 Eclipse Genie CLA 2017-08-23 19:09:55 EDT
New Gerrit change created: https://git.eclipse.org/r/103588
Comment 6 Eclipse Genie CLA 2017-09-27 04:13:53 EDT
New Gerrit change created: https://git.eclipse.org/r/105839
Comment 7 Till Brychcy CLA 2017-09-27 04:15:42 EDT
(In reply to Eclipse Genie from comment #6)
> New Gerrit change created: https://git.eclipse.org/r/105839

gerrit for the master
Comment 8 Noopur Gupta CLA 2017-12-18 04:49:33 EST
(In reply to Till Brychcy from comment #7)
> (In reply to Eclipse Genie from comment #6)
> > New Gerrit change created: https://git.eclipse.org/r/105839
> gerrit for the master
- Create a Java project.
- Select project name in Package Explorer.
- Invoke "JUnit Test Case" or "JUnit Test Suite" wizard. We get this exception:

java.lang.NullPointerException
	at org.eclipse.jdt.ui.wizards.NewContainerWizardPage.initContainerPage(NewContainerWizardPage.java:158)
	at org.eclipse.jdt.junit.wizards.NewTestCaseWizardPageOne.init(NewTestCaseWizardPageOne.java:226)
...
Comment 9 Till Brychcy CLA 2017-12-18 05:38:21 EST
(In reply to Noopur Gupta from comment #8)
> (In reply to Till Brychcy from comment #7)
> > (In reply to Eclipse Genie from comment #6)
> > > New Gerrit change created: https://git.eclipse.org/r/105839
> > gerrit for the master
> - Create a Java project.
> - Select project name in Package Explorer.
> - Invoke "JUnit Test Case" or "JUnit Test Suite" wizard. We get this
> exception:
> 
> java.lang.NullPointerException
> 	at
> org.eclipse.jdt.ui.wizards.NewContainerWizardPage.
> initContainerPage(NewContainerWizardPage.java:158)
> 	at
> org.eclipse.jdt.junit.wizards.NewTestCaseWizardPageOne.
> init(NewTestCaseWizardPageOne.java:226)
> ...

Thanks, a null check was missing.
I've updated the gerrit.
Comment 11 Till Brychcy CLA 2018-01-12 15:07:14 EST
(In reply to Eclipse Genie from comment #10)
> Gerrit change https://git.eclipse.org/r/105839 was merged to [master].
> Commit:
> http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/
> ?id=e078c4d50c5ac22db54ca327596e5280e98c1c60

Released for 4.8M5
Comment 12 Till Brychcy CLA 2018-01-17 11:41:09 EST
*** Bug 529944 has been marked as a duplicate of this bug. ***
Comment 13 Noopur Gupta CLA 2018-01-23 07:24:28 EST
Verified in I20180122-2000.
Comment 14 Till Brychcy CLA 2018-02-19 11:00:24 EST
*** Bug 77980 has been marked as a duplicate of this bug. ***
Comment 15 Till Brychcy CLA 2018-02-19 11:03:14 EST
*** Bug 49611 has been marked as a duplicate of this bug. ***