Is Unit Test required for Xcode Bots Continuous Integration? - unit-testing

I don't have Unit Test script yet. I just want to see that the the integration itself is working and show 'Passed' results, is it possible without set of unit test? Currently, I always get Failed status on Summary of Results.

When creating the bot you can uncheck "Perform Test Action" and the bot will not run any unit tests. If you already created the bot you can go the bot under Log Navigator, select it and choose Edit Bot. You will be able to do the same thing there.

Although you haven't created unit tests yourself they are probably already in the project.
If you created your test project from one of the project templates, unit tests are included by default.
The unit tests included by default have a single test that always fails. Locate the unit test and comment out the XCTFail line in the [your project name]Tests.m file
//XCTFail(#"No implementation for \"%s\"", __PRETTY_FUNCTION__);

Related

Live Unit Testing doesn't copy over data file used by test

I have a test that loads and processes a .json file. The file is part of the project and marked as "copy always" so that it's present in the build directory of the test, and I have veryfied that this does work on manual test run.
Live Unit Testing instead disregards this setting and fails the test as the file is not found. Is there any option other then disabling the test for live testing?
I solved this issue by moving the file I wanted to read in a subfolder of my unit test project, and then stopping and starting Live Unit Testing

Debug one unit test in VSCode

I have a number of unit tests in VSCode which I want to debug. The problem is I want to debug only one unit test. By default VS Code runs all the unit tests. I want to specify only one unit test to run like in Visual Studio. Is there any way to do this?
According to the unit test framework you are using you should be able to create a config.json or something similar where you can set options for your tests. Within this config you should be able to specify the path of all unit tests that shall be executed. For example when you are running javaScript unit tests with jasmine you can set something like this in your config.json:
"spec_dir": "./out/test/unittest",
"spec_files": [
"**/*[tT]est.js"
]
Here you can check out how this behavior is done with mocha. To run only one unit test you just set an absolute path. For example
"spec_files": [
"./path/to/a/single/unittest.js"
]

WebStorm run all dart unit tests

In WebStorm 11 I want to create a run configuration which runs all dart tests in my project.
However there is no option to do this in the "Dart Test" configuration template. The only options are:
Test Kind: All in file, Test group, single test
Test file: must point to a .dart file, otherwise I get "Dart file is not found"
VM Options (text input)
If I point WebStorm to a single test file this command gets executed in the test window:
C:\path\to\dart\bin\dart.exe --ignore-unrecognized-flags --checked --trace_service_pause_events file:\\\C:\path\to\dart\bin\snapshots\pub.dart.snapshot run test:test -r json C:/path/to/project/test/someclass_test.dart
I don't want to create a run configuration for every unit test class I write, there must be a better way.
Currently I prefer to navigate to the project directory and just run
pub run test:test
This runs all tests which live in files ending with _test.dart which is perfectly what I want. More info here: https://github.com/dart-lang/test#running-tests
Is there no such option in WebStorm for dart developers?
Accordingly to WEB-14747 ticket this functionality is already implemented for the next major version.
You can try latest EAP build of WebStorm v12 here.
I guess that's currently not supported.
The feature to run tests this way is quite new anyway.
If you think this feature is important, lease create a feature request in https://youtrack.jetbrains.com/issues/WEB

Grails test-app classpath

I'm trying to use test support classes within my tests. I want these classes to be available for all different test types.
My directory structure is as follows;
/test/functional
/test/integration
/test/unit
/test/support
I have test helper classes within the /test/support folder that I would like to be available to each of the different test types.
I'm using GGTS and I've added the support folder to the classpath. But whenever I run my integration tests running 'test-app' I get a compiler 'unable to resolve class mypackage.support.MyClass
When I run my unit tests from within GGTS the support classes are found and used. I presume this is because the integration tests run my app in its own JVM.
Is there any way of telling grails to include my support package when running any of my tests?
I don't want my test support classes to be in my application source folders.
The reason that it works for your unit tests inside the IDE is that all source folders get compiled into one directory, and that is added to your classpath along with the jars GGTS picks up from the project dependencies. This is convenient but misleading, because it doesn't take into account that Grails uses different classpaths for run-app and each of the test phases, which you see when you run the integration tests. GGTS doesn't really run the tests; it runs the same grails test-app process that you do from the commandline, and captures its output and listens for build events so it can update its JUnit view.
It's possible to add extra jar files to the classpath for tests because you can hook into an Ant event and add it to the classpath before the tests start. But the compilation process is a lot more involved and it looks like it would be rather ugly/hackish to get it working, and would likely be brittle and stop working in the future when the Grails implementation changes.
Here are some specifics about why it'd be non-trivial. I was hoping that you could call GrailsProjectTestCompiler.compileTests() for your extra directory, but you need to compile it along with the test/unit directory for unit tests and the test/integration directory for integration tests, and the compiler (GrailsProjectTestCompiler) presumes that each test phase only needs to compile that one directory. That compiler uses Gant, and each test phase has its own Grailsc subclass (org.grails.test.compiler.GrailsTestCompiler and org.grails.test.compiler.GrailsIntegrationTestCompiler) registered as taskdefs. So it should be possible to subclass them and add logic to compile both the standard directory and the shared directory, and register those as replacements, but that requires also subclassing and reworking GrailsProjectTestRunner (which instantiates GrailsProjectTestCompiler), and hooking into an event to replace the projectTestRunner field in _GrailsTest.groovy with your custom one, and at this point my brain hurts and I don't want to think about this anymore :)
So instead of all this, I'd put the code in src/groovy and src/java, but in test-specific packages that make it easy to exclude the compiled classes from your WAR files. You can do that with a grails.war.resources closure in BuildConfig.groovy, e.g.
grails.war.resources = { stagingDir ->
println '\nDeleting test classes\n'
delete(verbose: true) {
// adjust as needed to only delete test-specific classes
fileset dir: stagingDir, includes: '**/test/**/*.class'
}
println '\nFinished deleting test classes\n'
}

How do I set-up XCTest unit testing with a Cocos2d-v3 / SpriteBuilder project?

I am using the new SpriteBuilder (was Cocosbuilder) and Cocos2d-v3 to build an interactive book. It is my normal practice to code using unit tests and I want this project to incorporate XCTest.
So far I have gone to the test navigator in Xcode, hit the '+' at the bottom and added a test target per Apple's documentation. Xcode then created a test target and a sample test class (just a .m file with a failing unit test).
I commented out the textExample, and hit Command+U to test - and it failed to compile...monumentally. Bazillions of errors and warnings.
Is there a simple way to solve this?