Reputation: 363
I am newbie in IntelliJ, I used to use NetBeans. My situation is the following:
I create the class and the corresponded test.
I create some method in the class.
Is there is any feature in IntelliJ for refactoring the test, so that the new method/function created will generate its corresponding test function in the test class? I stress that the test file is already generated.
Edit1: My aim is updating the current test, not generating a new one. I am looking to a feature which implements the new test function into the current test. Here is the situation with snippet code:
src/pack/Foo.java
package pack
class Foo {
\\ variables
public Foo (arguments){
\\ variable initialization
}
private void metho1(){ ... }
Test/pack/FooTest.groovy
package pack
class FooTest {
private static Foo tmp = new Foo (arguments)
void testmetho1(){ ... }
Foo.java
.src/pack/Foo.java
package pack
class Foo {
\\ variables
public Foo (arguments){
\\ variable initialization
}
private void metho1(){ ... }
private void metho2(){ ... }
private void metho3(){ ... }
FooTest.groovy
in such a way thatmetho2, metho3
created in Foo.java
will generate the functions tests for them.Test/pack/FooTest.groovy
package pack
class FooTest {
private static Foo tmp = new Foo (arguments)
void testmetho1(){ ... }
void testmetho1(){ ... }
void testmetho1(){ ... }
Upvotes: 2
Views: 314
Reputation: 371
I put my cursor on the new method name
press {Generate... (default Alt+Insert I think)}
Select 'Tests...'
select my method(s) I want to generate test scaffolding for
have it use the existing class.
Upvotes: 2
Reputation: 401905
Please check the documentation:
Create test methods
To create stub test methods in JUnit test classes, you can use the IntelliJ IDEA code generation feature.
Upvotes: 1