How to locate Intellji IDEA "Generate Test" related code? - intellij-idea

Right click on a open Java file, we can get Generate item:
Then click Test and go on, we can generate target Unit Test:
I want to develop a new Intellji IDEA plugin base on upper build-in 'Test generator' feature, I want to check related IDEA source code, I just guss may be in some .jar in com.jetbrains.ideaIC library, and fail to locate it for a long time:
I have no better idea about how to locate the code.
Could you tell me where is the related source code, or how to better locate it?
Thanks for your idea!!!

This is the related package in the source code https://github.com/JetBrains/intellij-community/tree/0e2aa4030ee763c9b0c828f0b5119f4cdcc66f35/java/java-impl/src/com/intellij/testIntegration/createTest

Related

Running a pre-existing .java

I'm switching from Sublime Text 3 to IntelliJ, I had a test.java file on my desktop that I used for small testing but now I am not able run the same in IntelliJ, the problem is it's not showing the file when I select run.
I tried experimenting with different projects created through IntelliJ and understand that I need to set Project to run the code, but again I don't see the file I want.
Here is the project selection screen
Here is what happens when I hit run
See this answer and this document.
You need to configure the content and source roots inside the Java module.
If you right click on test.java and click "Run 'test'", that will attempt to run your main class. Although you may have a NullPointer exception in your code. When you attempt to access a.get(0), the value will return null as there are no Integers in your ArrayList. Also generally class files are named with uppercase first characters. Hope this helps!

Locate code author (annotate/blame) in place

Besides having this "annotate" option on the "Differences Viewer" located on the left side of a class, there is a new feature in IntelliJ for locating code author and commit message in place.
For example, if you have your cursor on some code in Java class, a grey text will be displayed beside the java line of code, containing the Author and his commit message for this line. See image below.
screenshot from IntelliJ
My IntelliJ is up-to-date 2019.2, but I never had this feature. Does someone know how to enable it or get it to work on my workplace?
Many thanks.
This functionality is provided by the GitToolBox plugin.

Intellij : Adding 'JUnit' to context menu when creating new file

Currently in Intellij if I try to create a new file via "New > whatever", I don't see any option to choose a JUnit file. I dug deeper and found out the "Edit File Templates...".
While you can add a variety of files from there to the context menu, there is no ability to choose JUnit.
If you browse over to "Code" tab you can see various JUnit templates. However I have no idea if these are just code generation templates instead of file generation templates. And besides, there is no option to port them to the "Files" tab.
The closest SO thread describing this issue is this and it failed to match my needs.
Mind you I am relatively new to Intellij and I come from eclipse.
P.S: I am aware you can generate tests from existing classes. I am currently trying to implement TDD so that does not answer my needs.
While I don't have an answer for this exact question, I think there's an easier way to handle the underlying requirements (easily creating tests):
Navigate to the class you want to test and press ALT+ENTER. In the context menu, pick "Create Test":
After you choose it, you'll get a dialog with several options including the framework to use (e.g., JUnit 5, JUnit 5, TestNG), the methods you want to generate test stubs for, etc:

List of all errors in project in CLion

CLion 2016.2 helpfully detects potential errors in the file you're editing, which can be seen in the validation bar to the right of the code.
That's just a single file though, is there a way (like a tool window) to get a list of all such warnings in the whole project, or specific parts of it?
Bonus points if it also lists warnings and errors from the compiler, though that's less important, because the compiler output already includes any it found.
Yes, it is possible. The feature you are looking for is called the Inspector.
Do: Find Action... | Inspect Code. It will show a pop-up that will allow you to select the scope: file, whole project, custom, and the Inspection profile (you can choose the type of errors you want to see):
After clicking OK, this is an example of the output, that you can navigate with the mouse or with keyboard shortcuts:
In version 2017.2, I have it under Code | Inspect Code....
You can also right click a folder in Project view and select Inspect Code... there to be able to check only that folder.

No coverage in 'all classes in scope' in Intellij

In Intellij IDEA 14.1.5 Community edition, I imported maven to get coverage from jacoco.exec file. Steps followed
right click on imported module.
select Analyze-->Show Converage Data.
provided valid jacoc.exec file and click 'show selected'
Instead of coverage i'm getting error as no coverage in 'all classes in scope'
can anybody suggest what is wrong?
I had the same thing happen to me.
I was able to fix this by going to "Edit Configurations", to the "Code Coverage" tab.
I'm not sure what caused it, but the wrong package namespace was listed there. I updated the entry there and my subsequent test run with code coverage succeeded.
It happens if your test class and class to test are in different package structures.
My test class was in:
com.tools.api
Class to be tested was in:
com.tools.ws
Once I've corrected the pattern as com.tools.* in the code coverage tab, I was able to see coverage results.
I had the same problem and found solution here.
In the Code Coverage tab, define the following options:
Specify the scope to measure code coverage for. Do one of the following:
To specify a class, click the Add Class button.
To specify a package, click the Add Package button.
I was able to fix this issue by:
Open Edit Configurations menu
Click on Modify Options > Coverage settings > Specify classes and packages
In the new box that appears, click on the plus to add a package
Select a high level package from the project