Better Control over test suites in SenTesting Kit/OCUnit - objective-c

It seems that adding a class to my Xcode 4 Testing project that begins with test... automatically adds it to the testing run, but is there a way for me to have the test suites I want to run defined in a class so I can easily toggle them on and off? I would like to be able to manually register a suite then comment it out if it is not required. I don't want to have to add and remove classes from the Testing target.

In Xcode4 Edit Scheme, select "Test", click the disclosure triangle and click "Test". You will be able to select classes or individual tests.

Related

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:

Why do I have to run 'rebuild project' for every change in Intellij?

For any change I made to my class, which contains a main() method, I have to run "Build->rebuild project", to make the changes effective. I am afraid my environment or settings have a problem.
Please help.
Please check that you still have Build step in the Before launch setting of the Run/Debug configuration. This is the default, but you could have removed it by accidentally clicking on the — icon.
I think you'll have to repeat this for every JUnit test case.
To alter the behaviour for all test cases:
Run -> Edit Configurations...
In left-hand column, select Templates -> JUnit
Make your changes
Hit OK
I had the same problem and I solved it setting the SDK. You need to go in Project Setting and select the Project tab, as show below
Then you can download a JDK or add a new SDK. Finally, you click on OK and run the code.

Changing the sequence of test cases in Selenium IDE

For example,
I have several test cases here when recording. And now I want to take test case "exp11141" to the first one, but I can't drag and drop the test case in Selenium IDE.
Is there a way to change the sequence of test cases in Selenium IDE?
I mean just in the IDE, not to modify any code. Thanks for help!
Yes you can! (control the order of the tests in the User Interface)
I don't recall when this was introduced but I'm currently running v3.17.0.
In Selenium IDE by default you're looking at Tests which shows the tests, I believe, in the chronological order you recorded them.
If you click the word "Tests", and choose instead "Test Suites" you should see the default test suite. In that view you can add a new suite or use the Default Suite.
Taking the Default Suite as our example, to the right of the name of the suite you'll see an icon (for me in Windows it's triple dots stacked vertically)
Clicking that icon gives a menu that allows you to choose:
Add tests
Rename
Delete
Settings
Export
By clicking "Add tests" you get a select tests dialogue with the names of all your saved tests, each with a checkbox beside it. Check any unchecked checkboxes first. All of them!
Now press enter to save or, if they were all already checked, escape to exit.
Now, viewing your suite you CAN click and drag to re-order the tests! So for the OP's question, in the suite click and drag that one to the top and off you go!
When you run a suite (icon with right-pointing triangle and three horizontal lines) or using shortcut (Ctrl-Shift-R) the tests will run in that order.
By creating different suites, I have created alternate combinations of tests from my total list to run different scenarios.
You should be able to drag and drop, that is part of the IDE functionality. If that isn't working then something may be wrong with your IDE install. Other than that there is no other way within the IDE to reorder the tests, you'd need to build the suite again by adding in the test cases from the file menu.
I'm not sure why you're against editing it outside of the IDE, but it is incredibly simple, as it would just be 1 cut and paste. If you open the suite file in a text editor you'll see something like this within it.
<body>
<table id="suiteTable" cellpadding="1" cellspacing="1" border="1" class="selenium"><tbody>
<tr><td><b>Test Suite</b></td></tr>
<tr><td>TestCase1</td></tr>
<tr><td>TestCase2</td></tr>
<tr><td>TestCase3</td></tr>
</tbody></table>
</body>
All you'd need to do is cut the row of the test case you want to move and paste it in at the top

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

Run unit tests in IntelliJ IDEA from multiple modules together

How can I run all tests from two or more IDEA modules at once?
I'm using many modules and it is important to run all of the unit tests often and when I choose more than one folder to run, there's no 'run' option on the context menu any more.
Best way way: (edit after 3 years)
There is even a better way to achieve this. From the JetBrains JUnit Run Configuration docs:
Select menu "Run" → "Edit Configurations...". Click green plus in left top corner and select JUnit.
Select "Test kind" to "Pattern" and enter this regexp exactly as you see it: ^(?!.*IT$).*$ (it starts with caret ^ and ends with dollar $). This regexp says: all tests that do not finish with IT in their name.
Note: The regexp will match against the qualified file names, making it easy to exclude by module/packages as well. If your integration tests are grouped in a package com.me.integrationtests, the regex to match everything not in this package would be ^(?!.*com\.me\.integrationtests.*).*$.
Select "Search for tests" to "In whole project". Working directory should be set to top module working directory (it should be set by default).
Enter a Name for your test like "All Unit tests". I also prefer to mark "Share" option so this configuration won't disappear later. Click Apply and OK.
You can experiment with this regexp to fit your needs.
Original answer:
It is doable, although it's not comfortable.
Select first module, right-click on test/java directory and "Run All Tests". It creates test configuration.
Select "Edit configurations" and check "Share" on newly created configuration so it will be saved.
Select second module, "Run All Tests" on it, and check "Share" on this configuration as well.
In "Before launch" section, click "+" and select "Run Another Configuration" and then select first module's configuration.
This way you run configurations in a sequence and every configuration gets a new tab. Still, better than nothing.
Select all modules, right-click them and choose to run all tests. This will create a configuration called "Whole Project" which you can run again at any time.
I found this better than the accepted answer because this runs the unit tests separately for each module. If your test cases use module-specific resources during its run-time then the accepted answer's best way won't work.
Select all modules
Right click and choose to run all tests
Get a new run configuration
You have to create a "Run Configuration":
Go to the dropdown on the top, at the right hand of the "Make" button and click on it
Select "Edit Configurations"
Now click on the "+" button to add a new run configuration and select JUnit
Then, when configuring the "Run Configuration", you'll find a "Test Kind" dropdown, select "All classes in directory"
Select the directory you want to use as the root, you can choose the top level directory for your project or any of the directories for your modules.
Select the IntelliJ module from where picking up the classpath (it can be the top level project if it has a classpath)
For me both solutions didn't work or didn't work es expected.
For me I have 3 modules. My modules dependencies look like this
Presentation -> Domain -> Data
I just wanted to execute all tests together. So I came up with the 'Across module dependencies' approach
My Settings look like this:
This worked for me for a project with multiple modules.
Create a new JUnit run/debug configuration.
Test kind: 'All in package'
Search for tests: 'Whole project'
You will have to specify a working directory as well.
Another not so obvious case is when code coverage is needed on more than one project. The naive solution would be to select multiple projects and run all unit tests in them at once. As it turns out, unit tests may fail if the classpath changes and IntelliJ has exactly one classpath entry per run configuration. In this case, running unit tests on projects sequentially is actually sufficient. That's because at the end of each run IntelliJ (2017.2.5 Community Edition) asks if the collected coverage should replace or should be added to previously collected coverage stats.
If you use Gradle and have multiple modules, you can do it that way:
make sure IntelliJ is set to use Gradle to run the tests (Settings/Build, Execution, Deployment/Build Tools/Gradle -> Run tests using: Gradle)
right click over a module in the Project navigator and select Run test in [module name]
once done, left click on the configuration that was created in the top toolbar and select Edit Configurations...
in the Run field, simply add more modules just after the first one, for example, if you want to run tests in modules foo, bar and baz: :foo:test :bar:test :baz:test --tests *
rename the configuration, for example Test Foo + Bar + Baz
Now you can just run the configuration to perform the tests you need.