I am using Citrus TestNGCitrusTestDesigner, I have a few classes annotated with #Test. Each class have a few methods. Each method annotated #Test and #CitrusTest. When I am configuring tests that should be executed during mvn clean package integration-test - I am changing #Test(enabled=true) to true or false. How can I do this more effectively? I found this doc: http://www.citrusframework.org/reference/1.0/html/testsuite.html#testsuite-tasks but it is for an old version. Doesn't work in Citrus Framework 2.X.
Citrus runs with TestNG or JUnit framework. This means that you can reuse the mechanisms of these frameworks in order to group tests or define a test suite.
With TestNG for instance you can use different groups of tests or create a testng.xml file that defines the tests to execute in a suite (http://testng.org/doc/documentation-main.html#testng-xml).
With TestNG or JUnit integration in build tools like Maven or Gradle the tests are executable from command line or Java IDE.
Related
is there any possibility to annotate / tag the CDC generated tests?
I would like to group the cdc tests and execute them as separate step in my build pipeline.
They are all present under target or build and then /generated-test-sources/contracts. You can by default exclude those paths and have a separate profile in maven or task in gradle that will include those paths when you want to run contract tests
As far as I understand(beginner level on Spring Cloud Contract), the contract tests generated from the groovy contracts are with junit.
What if I want to use TestNG? Basically I want to group my tests with TestNG annotation #Test(groups="unit") and #Test(groups="contract") in order to separate unit tests and contract tests using ssomething like mvn test -Dgroups=unit and mvn test -Dgroups=contract.
Thank you for your help.
Currently, we don't support this out of the box. You would have to write your own org.springframework.cloud.contract.verifier.builder.SingleTestGenerator implementation (by extending, for example, the JavaTestGenerator and referencing it in spring.factories file) but that can be quite time-consuming, unfortunately.
We are looking forward to using squashTA to manage our tests. The problem we are facing is that we already have a big automated tests collection and aren't able to make them run via squash TM using squash TA.
Our tests are using junit+selenium WebDriver+SpringFramework.
Currently, we launch our automated tests via maven (in commandLine), and we have a jenkins server running them regularly.
We tried to reuse our tests in a squash TA project, putting them in src/squashta/resources/selenium/java
But code in this folder doesn't even support java packages. It's like the java in the example isn't real java but a fake java parse by squashTA.
Is there any mean of using such already existing tests with squash(TA/TM) ?
Or, any alternatives you know that could do the job ? (we are currently using testlink and must change).
If your selenium test is in :
src/squashTA/resources/selenium-test/src/main/java/org/squashtest/ta/selenium/PetStoreTest.java
With a such structure, the test automation script to run the selenium test (which is in the package org.squashtest.ta.selenium) is :
TEST :
LOAD selenium-test/src/test AS seleniumTestSource
CONVERT seleniumTestSource TO script.java(compile) AS seleniumTestCompiled
CONVERT seleniumTestCompiled TO script.java.selenium2(script) USING $(org.squashtest.ta.selenium.PetStoreTest) AS seleniumTest
EXECUTE execute WITH seleniumTest AS seleniumResult
ASSERT seleniumResult IS success
If your selenium test has some dependencies to other libraries (like to spring in your case), you have to add those depencencies as dependency of the squash-ta-maven-plugin in the pom.xml of your Squash TA project
I have a suite with more than 500 test scenarios written in Web driver. I am using TestNG framework to execute the test cases.
Could you please suggest me how to execute specific test cases from the suite like 31, 45, 68 etc?
Thank you
If you have prefaced all of your tests with #Test, then in Eclipse with TestNG plugin, you can right click on the method name, and run it as a TestNG Test. You can also click on a class file, and only run that class. However, if you want to run test X and test Y that are in different tests, you can press Run Configurations... and add which methods you want run.
If you don't have the TestNG plugin, you can write an XML file that has the classes, methods, groups, or suites you want to run. It is described here
I use Simpletest test suites to run all tests, with different configuration methods. I've created one suite per config method, and it sets up the environment and then runs all tests.
Take a look at Adapter.php and Constants.php if that's unclear.
Now there seems to be support for test suites in PHPUnit, but as I understand it, it's merely for grouping tests with no support for setting up the environment or running PHP scripts.
How can I convert my test suites to PHPUnit? I'm open to rethink how the tests are structured :)
You can use test fixtures to setup your environment either before each test, or before each test suite:
http://www.phpunit.de/manual/3.6/en/fixtures.html#fixtures.more-setup-than-teardown
The methods you are looking for are
setUp() and tearDown() (called before/after each single test), and
setUpBeforeClass() and tearDownAfterClass() (called before/after each test class (suite)).
Apart from restructuring your test suite you should also be aware that the behaviour of the assertions in PHPUnit is different from SimpleTest.
While in SimpleTest you can test on an assertions result and execute further code after a failed assertion, you cannot in PHPUnit: test the return value of a method that triggers an error with PHPUnit
This will likely also force refactoring some of the actual tests.