How should I setup QUnit in combination with ReSharper 6.1 - unit-testing

ReSharper 6.1 comes with support for Unit Testing Javascript code using QUnit. Only thing I wonder about how to best set up my test environment. Right now I have all my JS files in \Scripts and the according filename-test.js in \Scripts\tests. Does it also work to put the test files in a dedicated test project?
Also I'm not sure where to put my html snippets. For me it looks like ReSharper does not support additional html files but creating the html using jQuery is a pain in the ass.

In this post you can see an example of how to set up ReSharper with QUnit http://blogs.jetbrains.com/dotnet/2011/03/resharper-6-introduces-support-for-javascript-unit-testing/
You can use reference paths to organize your code a little but different project AFAIK is not available.

Related

Is it possible to run UNIT TEST with Cypress standalone version similar to how Jasmine does it? (in browser)

Cypress allows for GUI testing in browser as well as Unit Testing using the NodeJS installation version.
But I was wondering if the standalone version, aside for UI testing, it also allows for Unit testing.
I don't seem to find any information in regards.
I am working on a website project that uses plain HTML + JS, meaning that there is no NodeJS involved nor anything similar.
I need to write some Unit tests for it.
If I was to use Jasmine, that provides a simple inline script linking such as <script type="text/javascript" src="lib/jasmine-{#.#.#}/jasmine.js"></script>.
But I'm not sure how it is done in Cypress, or if it is even possible.
It would be handy to be able to do Unit test and UI test with the same testing library.

Plugin to help copy/paste XML in android studio according to some pattern?

I use android studio for creating android apps. While designing the UI I mostly find myself copy pasting my custom made components to test different things out and to see how would they look when I actually populate the view with my component using some adapter. But when I duplicate my components I manually have to update there id's and other attributes in XML according to needs. But those changes mostly have some sort of pattern which I can always define using a regular expression.
So, in short is there any tool for android studio that can help me copy/paste XML by defining some pattern via regex or something else ?
Or should I see this as an opportunity to create my own plugin and start coding right away.
Android Studio (Version 3.3+) supports Live Templates, that you can make as per your use. These can be for .java as well as .xml file formats. See this official Android Developer Youtube channel.
More resources regarding templates in Android Studio:
How to make your own file templates in Android Studio - This is
a multi-part post.
Supercharging your app development speed with
custom file templates
A collection of some Android Studio Live
Templates - This is a Github repo.
You can also try to make repeatedly used classes, activities etc into a library package and reuse them across your projects. Add some tests to them to make sure they work as intended and with some CI/CD scripting and gradle plugins (like gradle-use-latest-versions-plugin) you can have them automatically upgrade to use latest dependency versions etc. Then all you'd need to do is pull them from a repository or include them as a library in your projects to reduce code redundancy.
Hope this helps.

Visual Studio Code: Execute Test scripts?

I am following the Redux Tutorial and try to implement it using TypeScript in Visual Studio Code. The tutorial makes use of the Expect library.
My question is: is there any chance I can execute the Expect-Tests (written in a *.ts file) directly from VisualStudio Code, or do I absolutely have to create a HTML page and run it in the browser? The latter seems extremely inconvenient. Please note that in this case, the file to run is a TypeScript file, so this answer unfortunately does not work, because node can't deal with TypeScript files directly.
It's not necessary to run TypeScript directly in node, you can compile your *.ts files into JavaScript *.js and run them.
You can play with a sample project to get the hang of it.
Basically, these are the steps to run your tests:
Compile your code from TypeScript to JavaScript.
Compile your tests from TypeScript to JavaScript.
Run tests in testing library of your choice (e.g. mocha).

Referencing Javascript Dependencies in Typescript Unit Test with Resharper

I'm writing an integration test to cover some Typescript classes that I've got, and those Typescript classes have dependencies on third-party JS libraries.
The Integration test is also written in Typescript. When I run the test using Resharper's built-in support, there is a JS error in the browser saying that the third-party dependencies can not be found. Of course, the test runner has not added references to them when constructing the test page for the browser. I try and add the references using the <reference> statement in the test file, but the IDE (VS 2013) complains that you can only use to refer to other Typescript files - not Javascript files.
How can I solve this problem?
I have used the Chutzpah test runner in the past, with its various plug-ins for VS, and that lets me define such references using the <chutzpah_reference> statement. But I was wondering if it was possible to just use Resharper from now on...
JetBrains has this on their radar for Resharper: https://youtrack.jetbrains.com/issue/RSRP-389196 where the following workaround is proposed.
Include references to *.d.ts files in your TypeScript test files. Then put your third-party JS libraries in matching .d.js files in the same directory.
For example, if you would want to reference the trial.js file, like you said, you can't just do this because typescript complains:
/// <reference path="scripts/trial.js" />
So instead, create a file at scripts/trial.d.ts and add
/// <reference path="scripts/trial.d.ts" />
Then rename (or copy) scripts/trial.js to scripts/trial.d.js.
The Resharper test runner will see the trial.d.ts reference and include the trial.d.js script in the test fixture HTML it generates.

What alternative to DUnit with C++ Builder?

I have some projects developed with C++ builder XE.
I would like to add some unit test, but the DUnit framework installed is nice for Delphi, but the integration with C++ builder is not so good (and very limited).
What other xUnit framework can I easily work with ?
In your case I'd start by asking Embarcadero for assistance. They want to fully support the developers who use their stuff, and automated unit testing is really critical to keeping them happy.
Until then, CppUnit works on any C++ code, but does not really integrate all that well with IDEs. The approach we've used is to create a new project to contain the tests, and have its linker include the path to the existing production project's .OBJ files. We set up a a project dependency so the test project depends on the production project.
In the Test project, we'll use different main.cpp files, one each for Debug and Release, and use conditionals to include/exclude the appropriate one from the Debug and Release builds.
For some "fake" integration, at least as far as running the tests go, in the DebugMain.cpp we'll load up the MFC TestRunner GUI, so the developer can click to select the tests they want to execute. In the ReleaseMain.cpp, we'll use the command line test runner, using the CompilerOutputter object which will let the build process know of success or failure. The output is also compatible with IDEs that interpret stuff like that, so you can click on a failed test report in the Output window, and the IDE takes you to the failing test assertion.