We've upgraded a VS2008 solution to VS2010 and then to VS2013 Pro. In VS2013 it all builds, but the unit tests all fail with the same error:
The unit test adapter failed to connect to the data source or read the
data.
The folder structure has not changed, and the test data files are all there in the correct location.
Here's a typical test:
[DeploymentItem(#"Autoscribe.Utility.Test\TestData\GetParameters1_RetrievesCorrectParameters.xml")]
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", #"|DataDirectory|\Autoscribe.Utility.Test\TestData\GetParameters1_RetrievesCorrectParameters.xml", "test-record", DataAccessMethod.Sequential)]
[TestMethod(), Description("String extensions")]
public void GetParameters1_RetrievesCorrectParameters()
{
// Get test data.
string input = TestContext.DataRow["input"].ToString();
string[] outputs = TestContext.DataRow["outputs"].ToString().Split(new char[] { ',' }, StringSplitOptions.None);
// etc
}
In VS2008 there was a wizard to set the test properties to connect the test data file to the test, and using this often fixed this class of problem,but this doesn't seem available in VS2013 Pro. Can someone tell me:
a) how to connect a test to a data file in VS2013 Pro without having to explicitly type the DataSource attribute, and
b) any suggestions on how to fix this problem?
The trick was to explicitly select the original testrun config. It seems the upgrade does not carry this forward.
Related
I'm trying to set up a test environment using VS2015. The test project and the project to be tested both reside in the same solution and I've added a reference to the project to be tested. The code to be tested is configured as a DLL. In The object browser, things look like this, which seems to suggest that my test subjects are available to the UnitTest1 project:
Still, when I actually try to use build a simple test case I get unresolved exteral UnitTest1 symbol[...].
The actual test code is:
TEST_METHOD(TestMethod1)
{
int value = 2;
Testee t;
t.set_attribute(value);
//TODO add actual assertions
}
Recently installed new TS version into VS2013 and tried to use protected modifier.
However TS validator shows me an error (and underlines protected word with a red line.
I get an error like
Use of future reserver word.
; expected
looks like it's looking into old TS definitions.
Checked the project file and there is 1.1 version of TypeScript.
also running tsc -v produces 1.3.0.
Does somebody of you guys experience that?
What i'm missing and what to do to fix that.
Thank you a lot for any help.
export class SomeClass {
protected metadata: Metadata;
protected subItems: SomeClass[];
constructor() {
}
}
thank you all guys. for your answers!
the reason was (oh, what's the shame =) ) the ReSharper.
It's validation was showing that error, suspending it i'm getting no errors now.
Looks like JetBrains guys should update their definitions like Web Essentials did.
As they aren't compatible with new TS version, 1.3. And no updates pending as for now.
Hope, it'll be useful for somebody else.
The answer to your question then is ReSharper 9.0 EAP.
It supports TypeScript 1.3 features: 'protected' modifier and tuples.
You're welcome to try it. Though, yes, it's a pre-release version, so overall stability is not strictly guaranteed.
Are you building from within Visual Studio, or from the command-line? What with different versions of the SDK being installed, as well as potentially the NPM package globally (if you've ever installed that), it can get quite messy as to which version gets picked up. For example, if I run 'where tsc' from the command prompt, I get the below hits (and this is without the 1.1 SDK on the path, though I am in the bin folder for testing the latest bits)
S:\src\TypeScript\bin>where tsc
S:\src\TypeScript\bin\tsc
S:\src\TypeScript\bin\tsc.js
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\tsc.exe
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\tsc.js
C:\Users\billti\AppData\Roaming\npm\tsc
C:\Users\billti\AppData\Roaming\npm\tsc.cmd
Can you verify via "where tsc" the locations and order you PATH is resolving the 'tsc' command?
That said, if you're building from within a VS project, it should locate the latest SDK via the build target. Does this also occur with a new TypeScript project (where the latest version and targets file should be referenced)?
Failing that, and I hate to say it... ready... did you try rebooting? :-) Sometimes updates to the PATH etc.. after an install don't get picked up until processes restart, and things like MSBuild can actually linger waiting for the next build as a perf optimization, rather than exit once the build is done (and thus may not pick up environment changes immediately).
It didn't work for me too. What I did to fix it was installing VS2013 Update 4 and after that, I executed the TypeScript 1.3 setup again and did a repair.
Also, you should make sure you don't have <TypeScriptToolsVersion>1.0</TypeScriptToolsVersion> in your csproject defined. Set it to 1.1 (not 1.3) or remove it entirely (then it will use the latest one). Hope that helps!
You can determine whether the issue is related to Visual Studio pointing at the wrong TypeScript version by following these steps.
Place this example code in C:\Temp\app.ts
interface Metadata {
something: string;
}
export class SomeClass {
protected metadata: Metadata;
protected subItems: SomeClass[];
constructor() {
}
}
export class OtherClass extends SomeClass {
constructor() {
super();
this.metadata = null;
}
}
var x = new SomeClass();
// Not allowed
// x.metadata = null;
Run the command:
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.1>tsc --module amd c:\Temp\app.ts
Taking care to ensure you are pointing at the 1.1 folder in the TypeScript SDK folder.
The output should be:
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.1>
i.e. nothing, except you now have an app.js file.
You can also re-run the test after uncommenting the x.metadata = null; line - at which point you should get the error:
c:/Temp/app.ts(22,1): error TS2445: Property 'metadata' is protected and only accessible within class 'SomeClass' and its subclasses.
Next Steps...
If the above fails, please supply details of the problem.
The only real answer we could give though it remove it and check the 1.1 folder is gone before re-installing it by fetching the installer fresh from the Microsoft website (perhaps you have a bad installer or there was some problem during installation?) You may also want to check that you are on Visual Studio Update 4, as I am testing it on Update 4.
If the above worked as expected, your Visual Studio is not pointing at the correct version.
This could be because of the project file as Dick van den Brink has correctly mentioned. Check that you have <TypeScriptToolsVersion>1.1</TypeScriptToolsVersion> and that it is the only element with this name.
It can also be down to any Visual Studio extensions that may be messing with your TypeScript (for example, if you had a really old version of Web Essentials - in which case, update it - if it is some other extension, try disabling it).
We are actually analyzing what we have to do if we migrate our application from VS2005 up to VS2010.
What i have done:
I opened all solutions in VS2010 and let convert vs the projects.
At the moment the production assemblies dont get an upgrade of the .NET Framework,
it has to target the framework 2.
The framework version of the unit test assemblies (MSTest) is switched to the version 4 by VS2010 automatically,
thats ok so far.
The Problem:
Some unit tests are failing cause they can't access a config file through the ConfigurationMananger.OpenExeConfiguration(ConfigurationUserLevel.None) call.
The following exception is thrown:
System.Configuration.ConfigurationErrorsException: An error occurred
loading a configuration file: Type is not resolved for member X ...
System.Runtime.Serialization.SerializationException: Type is not
resolved for member X
The member X is derived from GenericIdentity and is marked as [Serializable].
All needed files (configuration, assemblies) are up to date and are correctly deployed in the output folder.
I tried to switch the framework version of the production assemblies to version 4, but it didn't help.
I found this ressources, but they dont helped me.
post from stack
Anybody has an idea why i get the described behavior?
If i change my Identity from
public MyIdentity : GenericIdentity
{ }
to
public MyIdentity : MarshalByRefObject, IIdentity
{ }
all of my tests are gettin green.
I have written a bunch of unit tests inside VS2010 Express and tests being tests they sometimes fail. Since the express editions of VS don't allow plugins to run I can't simply spin up TestDriven.Net or an equivalent and debug the tests. To try and work around this I've converted my test assembly into a console app and made the main method look like this:
class CrappyHackToDebugUnitTestInVSExpress
{
public static void Main()
{
AppDomain.CurrentDomain.ExecuteAssemblyByName(
#"C:\Program Files\NUnit 2.5.5\bin\net-2.0\nunit-console.exe",
new [] { Assembly.GetExecutingAssembly().Location, "/framework:4.0" });
}
}
In theory I should be able to run this up, set break points in my test. If it worked it would be an acceptable work around, but I keep getting the following:
FileLoadException
Could not load file or assembly 'C:\\Program Files\\NUnit 2.5.5\\bin\\net-2.0\\nunit-console.exe'
or one of its dependencies. The given assembly name or codebase was invalid.
(Exception from HRESULT: 0x80131047)
Now the file exists and when run manually nunit-console runs fine. What might be my problem?
Basically you need to convert your assembly to Windows Forms app, add reference to the nunit-gui-runner.dll assembly and change your Main method to look like this:
[STAThread]
static void Main()
{
NUnit.Gui.AppEntry.Main(new string[] { Assembly.GetExecutingAssembly().Location });
}
here is another example:
...
using NUnit.Gui;
namespace __libs
{
class Program
{
[STAThread]
static void Main(string[] args)
{
NUnit.Gui.AppEntry.Main(new string[] { #"C:\test\bin\Debug\test.exe" });
}
}
}
This will allow you to step into certain tests but is not very good for a red green cycle, so you will want to use this only when debugging and not in other circumstances.
I played with your concept and it appears the issue isn't directly from loading the file, but from dependencies.
I used the following modified code:
And the error was actually a failure to locate nunit.core.dll, which is in the /lib directory.
try
{
String NUnitPath = #"C:\Program Files\NUnit 2.5.7\bin\net-2.0\nunit-console.exe";
AssemblyName asmName = System.Reflection.AssemblyName.GetAssemblyName(NUnitPath);
AppDomain.CurrentDomain.ExecuteAssemblyByName(asmName, new[] { Assembly.GetExecutingAssembly().Location, "/framework:4.0" });
}
catch (Exception ex)
{
Trace.WriteLine(ex.Message);
Trace.WriteLine(ex.StackTrace);
}
(I like getting System.Reflection.AssemblyName because you can inspect and see that everything's in order verses the raw file path.)
A quick bulk copy (xcopy nunit.*.dll) into my test projects' debug directory and it ran just fine. (It should be trivial to discover the minimal dependencies required)
Tested in VC# 2010 Express with NUnit 2.5.7 (breakpoints work, but I didn't really play with any other options.) Although I'm sure you could make a passable build option from it.
Cheers!
PS - First post here so I'm a bit untested as to getting the 'code' blocks formatted. Sorry in advance..
I had a similar problem trying to debug unit tests in VS C# express. Had a hard time getting it to work properly but then I found out about this project template. Works perfectly in C# Express!
http://visualstudiogallery.msdn.microsoft.com/b8a7a8fa-9f5a-4b9b-8e8b-8839a4364f26?SRC=VSIDE
C# Project Template
Integrated tests with Visual Studio, including Visual C# Express
version
Self contained NUnit console runner. Allow to write test fixtures and
test, running from Visual Studio simply by pressing F5 (support test
debugging), or Ctrl-F5 free run with results in console window. In
case of test failure indicate by beep sound.
Contains essential NUnit modules to start test project. No external
dependencies. Simply create new project, using NUnit Test Application
template.
While not a torrent, but some articles can be found on the net about function testing (particularly http://blogs.oracle.com/geertjan/entry/gui_testing_on_the_netbeans). However the tools mentioned by them do not seem to be maintained, or don't have a plugin working with the most recent version of Netbeans (6.8).
Do you have any function test setup for GUI? What is your level of integration into the development process (IDE integration, ant, etc).
Additional candy is that Netbeans is not only the IDE, but the GUI app is also developed for Netbeans 6.8 Platform (so I'm mainly interested in GUI testing NB-platform apps, but tips for any Swing apps in general would be a help too).
The NetBeans developers do a lot of functional testing and that testing is supported as part of the NetBeans module project.
One of the modules that I work with that has functional tests is here: http://hg.netbeans.org/web-main/file/tip/j2ee.sun.appsrv81
If you create an nbm module project, there are not functional tests defined by default, so you need to create some directories and the like 'by hand' on the Files explorer:
test/qa-functional/src
an initial test
This is a minimal test to get you started.
package a;
import junit.framework.Test;
import org.netbeans.junit.NbTestCase;
import org.netbeans.junit.NbModuleSuite;
public class SampleTest extends NbTestCase {
private final int SLEEP = 10000;
public SampleTest(String testName) {
super(testName);
}
public void testBogus() {
}
public static Test suite() {
return NbModuleSuite.create(
NbModuleSuite.createConfiguration(SampleTest.class).
addTest(SampleTest.class, new String[] { "testBogus"}).
enableModules(".*").clusters(".*"));
}
}
After these things are in place, you should be able to do the following:
Switch to the Files explorer (if you
aren't there already)
Right click on the node for the
build.xml file
Select the Run Target->Advanced...
item. A dialog will open.
Select test-qa-functional from the
combobox entry field labeled 'Select
targets to run:'
Press the Run button to dismiss the
dialog and execute the test.
Once you get the minimal test case running, you can start to examine the qa-functional test that have been written for the NetBeans IDE to learn more.