Default run configuration per TestNG group in IntelliJ IDEA

Is there any way in Intellij IDEA 12 to create a default TestNG run   configuration on a per TestNG group basis, so I can give a different VM   option for each one of them? Or maybe an annotation based parameter for  the test class in order to achieve the same effect?

Thanks in advance,
André.

7 comments

Hi Andre,

No, unfortunately you may configure only one default vm parameters. Actually the only problem is to make UI not too complicated but as you can't create group based configurations on the fly (just pressing Ctrl-Shift-F10) so I am not really sure that I understand why do you need such configuration.
Thanks

0

Hi Anna,

I'm using AspectJ to introduce AOP in my project, which requires an additional VM parameter, namely -javaagent:aspectjweaver.jar. While I need this parameter to be set for Integration tests, it doesn't make sense to include it for Unit testing, as they should not need to worry about whether the class they are testing is being weaved or not. This is even worse when dealing with Aspects that depend on Spring dependency injection mechanisms to initialize their fields. In that case, as Spring is not initialized during Unit tests, if AOP is enabled, the Aspects will be incomplete and produce null pointer exceptions.

If I had a default TestNG configuration for the Unit Tests group and another for the other tests, I could just remove the aspectjweaver java agent from the first while keeping it in the other. Otherwise, all our developers will need to manually change the generated configuration everytime they want to run a different Unit test (or at least for each Unit test that has Spring beans).

Thanks.

0

As far as I understand you'd like IDEA to detect to which group the test belongs and choose VM parameters according to that group, correct? That seems to me really complicated to configure and to use actually.

0

Yes, that's it, or something with similar results (like an annotation-based configuration).

From a user point of view, I don't know if it would be that much complex. It's basically allowing multiple default configurations and a filter field per configuration. Maven Surefire plugin already supports such configuration, my only problem is the static default IDE config.

Other possibility would be just to allow multiple default TestNG configurations, and then the user could pick one of them when running the test. This wouldn't require filters and IntelliJ detecting the test group, but it would be enough to remove the need for the user to edit each generated configuration manually.

0

It would be complex from user point of view in the UI. You would need to add multiple defult configurations (add/delete buttons), plus you would need to explain the rule where which configuration should be used.

Maven plugin doesn't need to detect which defaults to use as you fill it yourself. The same way you may create separate run configurations/save or share them and then reuse.

0

Maven needs to detect which defaults to use. I just set the rules. It needs to know when to apply what.

          <plugin>

                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <executions>
                    <execution>
                        <!--overwrite default surefire configuration by using default-test-->
                        <id>default-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>

                            <!--unit tests don't test AOP-->
                            <groups>unit_test</groups>
                            <argLine>-Xmx768m -XX:MaxPermSize=256m ${coverageAgent}</argLine>
                        </configuration>
                    </execution>
                    <execution>
                        <id>integration-tests</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <!--include AOP here-->
                            <groups>light_integration_test</groups>
                            <argLine>-Xmx768m -XX:MaxPermSize=256m ${coverageAgent} -javaagent:${aspectj.agent.jar}</argLine>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

The same way you may create separate run configurations/save or share them and then reuse.


It is useless to save a finished configuration in this case. If it was possible to save "configuration templates" from which you could instantiate concrete test configurations, that would be useful.

0

Please sign in to leave a comment.