I am new to using IntelliJ. I have only one grievance and that's the compiler. I prefer the way the Eclipse compiler will compile a project and skip classes with errors in them.
This is particularly a problem for if I want to write a unit test for a method I have to fix all errors in the entire project for running a single unit test!
You might say fix your project but I'm working on a project where people have already committed code with errors in it. How can I get around this, I saw there's an option to use the Eclipse compiler in the settings but this has made no difference/I don't know the argument to skip errors.
This fixed it for me on IntelliJ 14:
In Preferences->Build,Exec,Deploy->Compiler->Java Compiler, choose Eclipse compiler. Then check "Proceed on errors", which will appear once you choose the Eclipse compiler.
Then in Run->Edit Configurations expand the Defaults section on the left. Choose the configuration for your unit test framework (eg, JUnit or TestNG).
Then in the "Before launch" section, remove "Make" and add "Make, no error check"
Finally, you may need to delete any existing unit test run configurations so the new launch setting will take effect.
Not sure if this will be effective for what you're attempting to do and how your project is structured, but it worked perfectly well for me in my particular case, in that if your class has a main method, you can right click inside of the actual main method code and select "Run 'classname.main()'" from there.
This worked for me, but obviously may not be identical to your situation.
I got this from another answer located here: Intellij IDEA how to run a class not the entire project?
On IntelliJ 2018.1.4 (Linux): 2018-06-06
In File->Settings->Build,Exec,Deploy->Compiler->Java Compiler, choose Eclipse compiler from drop down. Option "Proceed on errors" should already checked (if not, mark tick on it), which will appear once you choose the Eclipse compiler.
Then in Run->Edit Configurations -> expand the Defaults section on the left. Choose the configuration for your unit test framework (eg, JUnit or TestNG).
Then in the "Before launch: Build,Activate tool window" section(see in end), remove "Build" and add "Build, no error check". Click apply and okay
Finally, you may need to delete any existing unit test run configurations so the new launch setting will take effect. This can be find from Run->Edit Configurations under (eg, JUnit or TestNG). or we can edit it
A clumsy way is to create a new module under your project file and make a test file in src folder of this new module
Related
Could someone please help me with an understanding of the Run Configurations in Eclipse?
Here is the issue I am trying to resolve:
I am developing a c++ application using CDT in Eclipse Luna. I have to two source files, let's say I have file_01.cpp and file_02.cpp. Both of them have main() function. Both of these files are in the same project. Essentially I want to compile and then run a configuration #1 and configuration #2 where the gcc compiler would only compile file_01.cpp and file_02.cpp respectfully. I achieved mixed success where under the same configuration I would apply a Resource Configuration filter, but this is inefficient since I have to do/undo same filtering operation many times. I believe this is what the configurations are used for.
I looked at the eclipse manual, found exact place where this topic is discussed. Unfortunately, there is not much info there and also I think that manual might be outdated (some of the menu items are not where manual claims them to be).
So my understanding is that I create a configuration, include whatever files I want to include, compile that configuration and then run that configuration. Question: How do I do that in Eclipse?
Many thanks!!
You can use build configurations for your purpose. You can exclude/include source files from specific build configurations. Run configurations can then be used to run the exe built using a specific build configuration. You can manage build configurations from the project context menu. You can exclude or include files or folders from a build configuration by choosing the potion from the context menu of the file or folder
I want to thank #Sasikanth for the pointer on the Eclipse. His answer helped me to understand how to do it. I just want to go over the process more in detail and explicitly for the benefit of others.
Situation:
let's say you have two files under the same project: file_01.cpp and file_02.cpp.
file_01.cpp has the following line:
int main(void){
cout<<"this is file_01"<<endl;
return 1;
}
file_02.cpp has the following line:
int main(void){
cout<<"this is file_02"<<endl;
return 1;
}
How do we work with two main() functions in the same project. How do we compile files separately and run them separately?
SOLUTION: (I am using eclipse-luna)
1) First, you want to go PROJECT->BUILD CONFIGURATIONS->MANAGE
A new window will open up and you can create some build profiles, lets say PROFILE_1 and PROFILE_2
2) Next, right click on file_01.cpp and choose RESOURCE CONFIGURATIONS->EXCLUDE FROM BUILD. In there choose whichever build profile you want to associate file_01.cpp. In our case: PROFILE_1. Do the same procedure for file_02.cpp
3) Now you are ready to compile each Build Configuration separately. First you need to choose the configuration you want to compile. go to PROJECT->BUILD CONFIGURATIONS->SET ACTIVE and choose the build config you want to compile. Then prese CTRL-B. Do the same thing for other configurations.
4) Now everything is compiled, but you need to tell Eclipse that it needs to run different configs. go to RUN->RUN CONFIGURATIONS. A new window will open up. Under c/c++ application, add a new profile. on the right hand side you will have an combo box choose "Build Configurations" where you can associate RUN config with BUILD config. This will tell the eclipse what to run and when. Once you create your run configs, press OK.
5) in last step, you want to run a specific configuration. For that, you go to toolbar and look for the "play" button. Right next to it, there will be an arrow. You click on it and choose the configuration you want to run.
That is it in detail!! Again big thanks to #Sasikanth for the pointer on how to do it. Feel free to ask questions is any. Thanks!!
We have two distinct team projects, both running in TFS 2013 / VS 2013. One of them always builds the whole solution when asked to run all tests in the Test Explorer window, while the other one does not build anything and just tries to run the tests again.
Sometimes we would like to prevent VS from building the whole solution, since we know it did not change or we just don't want to test against the modified changes, for instance.
What setting controls this behavior? I can't really see any differences between both projects to warrant different test behavior. I'm not using any settings file in neither of them, and this was tested with both projects completely cleaned (like deleting the .suo file for example).
I'm aware of two things that may help.
Set files in your solution to Do not copy or Copy if newer
In Tools -> Options -> Projects and Solutions -> Build and Run check the checkbox: Only build startup projects and dependencies on Run
I'm working with these settings and I don't have the issue thought I cannot guarantee it will help in your case.
To build only few projects, you can create a sub solution - meaning the solution will have only few projects and their dependencies.
To stop building every time, use the tools-options-Projects and solutions->Build and run
check, build only the Startup projects and dependencies
and select "never build" in the drop down "On run, when projects are out of date"
I changed my IDE from Eclipse to IDEA. I'm tring to configure it to work as effective as possible. I have following problem. I want IDEA to show me all files with compilation errors automatically after one file has been changed and causes the problem. I installed IntelliJ Eclipse Mode plugin and selected Eclipse compiler, but i have still following problem: In module-interfaces I have one interface - assume InterfaceA. Its implementation is contained in module-implementation1 Implementation1 and in module-implementation2 Implementation2 both depends on module-interfaces. Now when I change one interfaceA's method signature and save it, make is automatically triggered (eclipseMode plugin) but there is no compilation errors since in current module only interface resides. When I select all modules and select make selected modules compilation stops on the first module having errors i.e. module-implementation1 so I see only problem with Implementation1. Once I fix this implementation and start manually make process then IDE shows compilation error in Implementation2.
Is it possible to configure Intelij so that it compile all dependent modules and shows all files having compilation problems at all, as eclipse does?
Thanks in advance, it is really confusing to me.
See this answer. Basically, looks like it will be supported in IntelliJ 12
In VS 2010, I could right click a method and have MSTest create a unit test for me. Where is this feature in VS2012 pro?
The command is still there. go to Tools->Options->Environment->Keyboard. Search the shortcuts for createunittests. The appropriate command comes up in the dialog box. simply assign it a keyboard shortcut and its ready to go. Works exactly like the VS2010 once you use the shortcut you created.
Just ran into this myself just now. Here is the explanation:
http://connect.microsoft.com/VisualStudio/feedback/details/748493/missing-funtionality-of-creating-a-new-unit-test-from-editor
"The 'New Test' menu does not have any extension points where 3rd party adapters can plug-in. Therefore we decided to remove it. We moved all the New Test Project types into the File -> New -> Project dialog."
So it seems it was removed because it was made for MSTest only, and now they support several frameworks out of the box. But I still miss it as well... Should be able to default to MSTest och NUnit...
Should select Add not New item in FILE menu to add a Test project into current solution.
below steps are copied from Walkthrough: Creating and running unit tests for managed code
To create a unit test project:
On the File menu, choose Add, and then choose New Project ....
In the New Project dialog box, expand Installed, expand Visual C#,
and then choose Test.
From the list of templates, select Unit Test Project.
Hope it helpful.
I'm using Eclipse with C++ code via linked resources on Linux. The code analysis index seems to be corrupted (Goto definition lands the cursor close to, but not on, the definition) Refreshing resources doesn't fix it, neither does restarting Eclipse.
Is there a way to flush the index and rebuild it?
Right-click on your project, go under the Index submenu, and choose either "Rebuild," "Update with modified files," or "Freshen all files."
I don't know the difference between those three options, but one of "Update with modified files" or "Freshen all files" usually fixes it for me.
Also, I'm sure you've already done this, but make sure that you're running the latest version of the Eclipse CDT. Current versions seem to have much more reliable indexing than previous versions.
From http://dev.eclipse.org/mhonarc/lists/cdt-dev/msg10390.html, the differences between "Rebuild," "Update with modified files," or "Freshen all files":
Rebuild: Works for entire projects, only. Clears the index and indexes
the files from scratch. When cancelled it leaves you with an empty or
partial index.
Update with Modified Files: Works on a resource
selection. Checks on individual files whether the timestamp or the
scanner-config has been changed and updates the index for the changed
files.
Freshen All Files: Works on a resource selection. Updates the
selected files in the index. The index is not cleared, it is safe to
cancel the operation.
Go to your project properties -> C++ general -> Indexer.
Do this with 'project specific settings',
(or on 'Configure Workspace Settings...').
Deselect 'Enable Indexer' hit Apply.
Select 'Enable Indexer' hit Apply.
This should completely wipe out and rebuild the index.
Neither of the above worked for me (Eclipse Indigo), index still broken and refusing to rebuild properly. Until applied this one:
http://slsam2.blogspot.com/2012/02/eclipse-cdt-index-not-working.html
The crucial bit of the linked post is this:
Eclipse no longer treats your project as a C++ project. Choose menu File/New/Convert to a C/C++ project. It takes a while to index the source code.
I still wonder how Eclipse can uncontrollably shoot itself in the foot like that. I suspect that installing additional packages can trigger it. Perhaps JavaScript support in my case.
delete only the .pdom file under .metadata.plugins\org.eclipse.cdt.core helps, I got the indexer screwed after upgrading Neon.2 to Neon.3 and this seems to solve the problem.
(this comment already exists above but am not allowed to confirm it up there).
I found that I had the global indexer set to 'Use the build configuration specified in the project's indexer settings',
and the project's indexer set to NOT use project specific indexer settings.
Regardless, it was using the same fixed configuration for the indexer regardless of which configuration I had selected.
The fix:
Window-Preferences, C/C++, Indexer. Select "Use active build configuration" in section "Build configuration for the indexer".
Happy days.
Did you try adding -clean to the command line for the eclipse executable?
Eclipse no longer treats your project as a C++ project. Choose menu File/New/Convert to a C/C++ project. It takes a while to index the source code. worked for me
I started with trying Josh Kelleys and mmmmms answers without any luck, but I finally fixed it by checking my include paths.
One way to see them are in the Project Explorer, expand project and there should be an entry "Includes". Inside that, check for a small yellow warning triangle on each include path. If that triangle is present eclipse most likely doesn't recognize the path.
The include paths are edited through right-clicking on "Your project" in the Project explorer, then choose "Properties" --> C/C++ General --> Paths and Symbols --> Includes.
I see three language options, Assembly, Gnu C, Gnu C++. Choose the correct one before starting to add paths (likely Gnu C++). After adding all the paths, -->Apply --> Ok and rebuild index if you're asked to.
My erroneous workspace paths looked like MyProject/MyProject/folder when it was supposed to be MyProject/folder.
For me the "Problems"-view is always slow to update, even after rebuilding index. To be sure that the error is still there, double-click the problems entry so that eclipse opens/reloads the file in question. This often seems necessary for me to update the "Problems" view.
I don't really know if it was eclipse or my scm that messed it up. Anyway, hope it helps someone!
I use Luna and builds with an external makefile.