I'm using IntelliJ 10.0.2 to develop a Grails project. From the Grails view, If I right-click on MyIntegrationTest.groovy and run it individually (by choosing "MyIntegration..." from the right-click menu) the tests therein pass. The tests in this class also pass when I use the "Run Grails target" feature and specify "test-app".
However, if I right-click on Tests:integration and select Run "All Tests", some of the tests in MyIntegrationTest fail because dependencies are not injected. The speed with which the tests run also suggests that the Spring app context is not being created. Is there a way to run all integration tests (or all integration & unit tests) from within IntelliJ without resorting to the Grails command line?
Thanks in advance!
If its the same case as mine, here's how I've solved it. I had a grails project imported into IDEA with .ipr project style. You can check if your project is .ipr style if you have Project.ipr, Project.iws, Project.iml and Project-grailsPlugins.iml files in your project's main directory.
Close IDEA, backup (for safety if something goes wrong) and remove these 4 files. Then open IDEA and choose New Project. Select "Import grails project from existing sources", select your sources and be sure to select .idea - project style. IDEA should create new project fine. Be sure to check Porject structure (Ctrl-Shift-Alt-S) -> Project Settings -> Modules -> Sources. You should have two directories test/unit and test/integration marked green as Test sources.
If all goes well you should be able to right-click on Tests:integration and Tests:unit project directories. There should be Run "Grails tests:integration" and Run "Grails test:unit" options that you were missing.
With Intellij you've a choise to either run tests as Grails:integration, Grails:unit tests or to run them as plain Unit tests. If you chose to run Unit tests it will work for test/unit only and won't create spring contexts for integration. Right click on test/unit and choose Run->Grails:unit or right click on test/integration and choose Grails:integration. Grails plugin for IDEA should be installed.
I encountered a very similar problem but I actually see a slightly different, almost opposite, behaviour in Idea 10.5.2. I have the '.ipr' style project setup. If I right click on the integration test class or the integration test package, I only get the standard 'Run MyIntegrationTests . . .' option and it fails as per the poster's error message (rather than actually fires up the integration context as per the poster's described behavour). However if I right click on the 'Tests: Integration' top level item in Grails view, I get the 'Run "Grails tests:integr..." option, and it works perfectly.
To me this is fine, and I do not have to rebuild my project into the 'directory' based structure.
Related
I had this working on a previous project and now on a new project I've setup SpecFlow, got it generating tests from my feature file but I can't run the tests from the feature file and instead have to go to the code behind to run the tests. I've also installed the VS extension "Spec Flow for Visual Studio". What can I try?
as Greg suggested the first thing to check is that your config is set up correctly for ms test. you basically need this:
<specflow>
<unitTestProvider name="MSTest"/>
</specflow>
Also worth checking your generated feature.cs tests to see what unit test language they are in
I'm trying to get TFS to run my unit tests.
The name of the project assembly is Users.SystemTests.dll. It's located in ~/source/Users.SystemTests/bin/debug. The solution file is located in ~/source/Users.sln.
I've included the Nunit.VisualStudio.TestAdapter nuget package the in test assembly project.
The results of the build shows that the tests don't run.
What am I missing? They run fine locally via the Resharper test runner and I can also use nunit-console-x86.exe to run them.
Does this have something to do with the fact that I'm building a solution file? Maybe it's the output location being "AsConfigured?"
Ok, so I tracked this down on my own. It was twofold. The first problem was the the TestAdapter was not being output to the bin directory. The other piece was the Output Location. Setting copy local and then Output Location SingleFolder fixed the issue.
I do believe this is a bug in the tfs build. It works when you use SingleFolder or PerProject, but not AsConfigured. In the latter case the test runner don't find the testassemblies, and this is the same for both NUnit and MSTest, so it is not adapter specific.
The diagnostics log says:
Run VS Test Runner00:00:00
There were no matches for the search pattern C:\a\bin\**\*test*.dll
There were no matches for the search pattern C:\a\bin\**\*test*.appx
Is it practical/possible to separate jasmine tests into a separate visual studio project?
I am just getting started with angular, and am trying to write my tests before I start on the actual angular implementation. I will be writing my project in Visual Studio 2012 with the Chutzpah test runner, see this video. Currently, I am trying to figure out how to organize my folder structure. I know about angular-seed and yeoman, but those are ill suited to starting a .net project.
I am assuming that since unit tests in Visual Studio are usually separated into a separate test project, by convention, the jasmine tests should, too.
However, for java script, there are no project dlls to reference, so separating the tests out into a different project would require a lot of copy and pasting, I think.
You can do this with no copy/pasting. In your Jasmine tests you can add a /// <reference comment which posts to your source files (or the directory containing them). For example given this sturcture
/ProjectA /scripts
code1.js
code2.js
/TestProjectB test1.js
You can add this line at the top of your test1.js file to reference all your code files:
/// <reference path="../scripts" />
Traditionally, I've always kept unit tests in separate assemblies.
I've read both sides of the argument and prefer not to ship code that isn't production code, or to have additional deployment steps to remove tests from production code.
In order to reference javascript in my Web.Client.Tests assembly, for example, I use a post-build event to copy the files into the test project. For this I use robocopy - it looks something like this:
robocopy "$(ProjectDir)app" "$(SolutionDir)Tests\Presentation\Web.Client.Tests\app" /E /COPY:D /IS
robocopy "$(ProjectDir)Scripts" "$(SolutionDir)Tests\Presentation\Web.Client.Tests\Scripts" /E /COPY:D /IS
if errorlevel 1 GOTO :eof
The main con with this approach is that you have to build the project each time, like you'd have to with your C# code, to update the test project before running the tests.
Think you should use default folder structure as recomended by jasmine
here is a link showing default structure of jasmine
In a project using SpecFlow with this configuration:
<unitTestProvider name="MsTest.2010" />
The tests work normally when using only the default Visual Studio setup.
After installing ReSharper, the context menu commands "Run SpecFlow Scenarios" and "Debug SpecFlow Scenarios" stop working; when selected, nothing happens.
It seems this is because ReSharper sets its own test runner as default. The workaround is to open the options dialog (Tools | Options | SpecFlow | Default) and in the "Test Execution" section, set "Test Runner Tool" explicitly to "MsTest".
Unfortunately, when setting up new development machines, sometimes we forget to set this and the tests stop working after installing ReSharper, and someone has to remember this is the workaround.
The question is: would it be possible to set the "Test Runner Tool" option in the configuration file so it stays with the project, and not in the user settings? Is that what the runtimeProvider property of the unitTestProvider setting is for?
I know you asked about VS2010, but given the age of your question, I thought I'd try it in VS2012. I was able to get SpecFlow to work with MSTest without altering the Tools\Options\SpecFlow\Test Runner Tool setting (i.e. leaving it at "Auto"):
Install SpecFlow Extension to Visual Studio 2012
Select Tools\Extension and Updates
Search for "Specflow"
Install the extension
Re-start Visual Studio 2012 (SpecFlow menu items might not show up until you do this)
Create new class library project (e.g. MyProject.spec)
Add Specflow package via nuget
Right-click the project references node
Select Manage NuGet Packages
Search for "Specflow"
Select "Install"
Configure SpecFlow
Open the app.config file
Add the following entry:
Right-click the project references node
Add the following entry inside the <specFlow> node: <unitTestProvider name="MsTest" />
Create a new feature
Right-click the project node
Select Add\New Item\SpecFlow Feature File
Add the unit test assembly to the project
Right-click the project references node
Select "Add Reference"
Search Assemblies for "Microsoft.VisualStudio.QualityTools.UnitTestFramework"
Add the assembly
Generate Step Definitions
Double-click the features file to open it
Right click the white space at bottom of the features file
Select "Generate Step Definitions"
Run the tests
Select Test Explorer\Run All
Tests should run normally at this point
I'm trying to do an Ant build with FlashBuilder 4 for an Export Release Build. There is supposed to be a new (in FB4) ant task fb.exportReleaseBuild that will execute the release build. Reference to the usage is here:
http://help.adobe.com/en_US/flashbuilder/using/WSbde04e3d3e6474c4-59108b2e1215eb9d5e4-8000.html
When I include a target
..target name="exportRelease"
fb.exportReleaseBuild project="${flexproject}" ...
I generate an error indicating that the task can't be found:
Problem: failed to create task or type fb.exportReleaseBuild
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any presetde/macrodef declarations have taken place.
I look in flexTasks.jar and it doesn't include any flex.ant.exportReleaseBuild class despite having the latest jar.
Am I wrong in assuming I can run the exportReleaseBuild from an ant script?
You have probably solved this by now, but here's the answer in case someone else needs it.
The Ant compiler is telling you that it can't find the ExportReleaseBuild task. The reason is that when Ant is run from the IDE, it runs as a separate process to Flash Builder. When you run it from the command line it runs in the same process, which is why it works.
To get this to work in the IDE:
Open the build.xml file in Flash Builder
Go to Run -> External Tools -> External Tools Configuration...
Select Ant, then click the New Launch Configuration button
Enter a name for the build task
Select the Main tab:
Browse to the location of the build file
Browse to the location of the workspace
Select the JRE tab, then tick "run in the same JRE as this Workspace" (see image below)
Click Apply, then click Run
In future you can run the the task using the icon on the toolbar:
Just came across this situation myself, and after tweeting w/ #renaun (his blog post has some info as well: http://renaun.com/blog/2010/09/command-line-build-a-flash-builder-4-premium-feature/), it's pretty much useless for a CI build, unless you want to install FB4 premium, you can't run this task.
I was able to get it to run on my OSX environment by following the Adobe docs for it, but it doesn't mention that you have to basically run it from the command line tool. The ant that is installed as a plugin w/ the premium version has an importexport-ant.jar that is being referenced by Eclipse (standalone or plugin).
The only way I got it to run was via cmd line/terminal. It is tedious, and not really useful for a CI build. I did try to just grab the jar file, place it in the right spot, reference that in my ant script and build directly, but that made my compiler angry :(
I think I cracked it by setting up a shell script, and calling the shell script from an ant task.
This way you * are * using the headless Flash Builder modus, from within Flash Builder.
Full working example at:
https://gist.github.com/1077715
Thanks for the link lordB8r, that one got me thinking : )