Running single test with TestNG in Intellij IDEA - intellij-idea

How do you guys run single tests with IDEA's TestNG plugin? I tried creating a focus group, but it seems the TestNG plugin does not resolve dependencies to other tests automatically. Even when I comment out dependsOnMethods, it seems #BeforeMethod is not run.
Advice is greatly appreciated,
Robin

If you mean a single test method inside a test class there is a right-click option called Run "testMethod" where testMethod is the actual method name.
The short cut is ctrl+shift+F10.
If you put the cursor between methods (even outside the javadoc) or outside the entire class it will test all methods in that file.

Bring the class into focus in the editor, and then simply right-click, select run?

Related

Using 'Run with code coverage' with Intellj idea gets ClassFormatError

Recently I use JMockit and Junit4 for unit tests in intellj idea. When I run my test using the 'Run' button or the 'debug' button, it works fine. When I try to get my code coverage result using the 'Run with coverage' button, it gets ClassFormatError.
java.lang.ClassFormatError at
sun.instrument.InstrumentationImpl.redefineClasses0(Native Method)
It happens only when I try to mock a method in the class which I want to test, like
new Expectations(BaseValidator.class) {
{
BaseValidator.isExistAirLineByTwoCode(anyString);
returns(false, true);
}
};
I test another method in class 'BaseValidator' which calls the method 'isExistAirLineByTwoCode'.
I don't know if the cause of this problem is from idea or jmokit, even junit. By the way, I use jacoco for code coverage reports.
How can I fix this problem?
I found a workaround by switching to jacoco runner:
In the menu, click Run --> Edit Configuration --> choose your test under JUNIT category
change coverage runner to Jacoco .

How to run individual Angular/Jasmine test cases in IntelliJ

My angular code is organised into separate directories, one for each component. Each component has its corresponding spec.ts. How do I run specs from only one particular file using IntelliJ. It is not practical to mark each test case as fdescribe and fit. Is there a menu option which can let me do it?

Intelllij IDEA Ultimate 2018.1 groovy code completion does not work

I can create a Groovy project and even run it. But when I type main or print there are no auto-complete / code completion suggestions at all. I have groovy-2.4.1 in the external library folder along with Java 1.8. I find Intellij frustrating and non-intuitive to use.
In a groovy script main does show correct code completion but when I click enter it puts "main()" without the String[] args that I can see in the suggestion.
You have created a Groovy class where code has to be embedded into a class to be executable and where only class member declarations are expected (e.g. functions, fields). Select to create a Groovy script (or just delete class declaration) to be able to write executable code in top level file. See also Scripts versus classes.
I was having the same problem when I was in a rush and forgot to add a method in which to write the code. Just type 'psvm + Enter' inside the class. This will create a main method in which code completion will work. Also, you can remove the public keyword as classes and methods in Groovy are by default public.

Selenium: Check i the testcase pass or fail

Guys First of all I am totally new for Selenium.
I am having a automation project. In my project, I am creating a screenshot function to take screenshots of my event which I have created for my testcases. Now if my test cases passes then all screenshot should move to Pass folder, else fail folder.
I would like to know how to detect that my test case pass?
I know Nunit detects but I wanted to program it so that I cam place my screenshot as well as log file to pass or fail folder.
Program in C#
Selenium
Nunit to run my test case.
I think you meant was this. But there is work around for this. You need to add your code accordingly.
if (TestContext.CurrentContext.Result.Outcome.Equals(ResultState.Failure))
{
IntegrationTest.WriteInLog("FAILS");
}
else if (TestContext.CurrentContext.Result.Outcome.Equals(ResultState.Success))
{
IntegrationTest.WriteInLog("SUCESS");
}
Check status property and compare it with TestStatus enum at teardown method.
NUnit2:
TestContext.CurrentContext.Result.Status
NUnit3:
TestContext.CurrentContext.Result.Outcome.Status

MoreUnit Plugin for Intellij

I am looking for a moreUnit like plugin for Intellij
This are the features I mostly use and miss in Intellij:
create a new test method from the method under test
Marker on method under test indicating that a corresponding test method exist
jump to the test method (not only the class) from method under test.
execute corresponding test method from method under test.
I saw there is plugin called MoreUnit but the only thing it does is jump to test/to class under test. This is function does intellij out of the box with CMD+SHIFT+T.
After a few years there is now a port of moreunit to intellij
https://github.com/MoreUnit/org.moreunit.intellij.plugin