I'm having an issue with Nunit where I cannot find an image file when I run my tests and each time it looks for images it looks in the Nunit folder instead of looking inside the folder where the binary resides. Below is a detailed description of what's happening.
I'm building a binary that is under test which contains the definition for some game elements and png files which will define the sprites I'm using (for sanity sake call it Binary1)
Nunit runs tests from a seperate binary (Binary1Test) executing test methods against the first binary (Binary1).
All tests pass, unless the test executes code in Binary1 which then requires Binary1 to use one of the image files (which are defined via a relative path). When the method is called, Nunit throws a file not found exception stating that it cannot find the file and states it's looking inside of the Program Files\Nunit.net 2.0 folder
So I have no idea why the code is doing this, and to make matters more confusing when I pull up Enviornment.CurrentDirectory it gives me the correct path (the path to my debug folder) and not the path to nunit. Also if I use this instead of using the relative path, my tests will run without issue. So my question is, does anyone know why in the case of loading relative paths from within my binary that nunit decides to use it's directory instead of the directory where the binary is located and where the images are stored? Thanks.
I'm not sure why this is happening, but wanted to mention something that might help you troubleshoot a little. Do you have any Path Constraint assertions in your tests? It might help you troubleshoot this.
Here's the NUnit.org link for the syntax: http://www.nunit.org/index.php/extensions/docs/2.4/files/index.php?p=pathConstraints&r=2.5.1
Here's an example (from the above link) of the syntax for relative paths. You might want to assert that your relative path is the same as an absolute path and see what is going on. At least you'll have a specific failing test about paths that you'll need to get passing.
Assert.That( "/folder1/./junk/../folder2",
Is.SamePath( "/folder1/folder2" ) );
Assert.That( "/folder1/./junk/../folder2/x",
Is.Not.SamePath( "/folder1/folder2" ) );
Related
I'm trying to understand the logic behind TFS 2013 Copy Files action's Content filter syntax. I have a simple solution with a couple of projects and some test projects, which unfortunately have huge test files. I don't want the test projects or the files in the drop folder. Test projects are named like Project.Test, Project2.Test etc.
I tried to filter them like this:
**\bin\$(BuildPlatform)\$(BuildConfiguration)\**;-:**\*.Test\**
But this doesn't copy anything.
Test files are located in directories called TestFiles.
This also filters out everything:
**\bin\$(BuildPlatform)\$(BuildConfiguration)\**;-:**\TestFiles\**
If the first part matches the correct files in bin directory, how can the second part them filter them out? I don't see how that can match the same files.
Solution to my problem was to use a different syntax to exclude certain directories (*.Test here):
**\!(*.Test)\bin\$(BuildPlatform)\$(BuildConfiguration)\**
I have this iOS module that creates and writes to some plist files in NSApplicationSupportDirectory, and I'd like to test that the module is performing these writes correctly. However, the writes don't seem to be going through - after calling the module method, the file seems to not exist. I've also tried writing to the desired file directly from the unit test module, and that doesn't seem to do anything either - using NSDictionary writeToFile returns NO, indicating that the write failed.
Is it impossible to write to this directory from a unit test environment, or is it more likely that I just screwed something up? And if it is indeed impossible to perform this write, what would the proper way to test this behavior be? If anyone needs more details, I'd be happy to provide them.
Thanks!
Discovered my own error: The NSApplicationSupportDirectory simply doesn't exist by default (this is why the write is failing). You need to create the directory before you can use it. See this post:
iOS: Can't save file to 'Application Support' folder, but can to 'Documents'
I am working on product testing automation. I am using Jenkins to create a job that will first browse some file in a directory. But I got a problem with Conditional Step in File Exist condition. It is not working when I search *.job file, it only works with specific file name I put. Sorry I don't have enough reputation to post picture :)
Anyone can help me solve this issue. Thank so much for reading
I don't think File Exists supports more than one file, you could try the "File match condition". Definitions below:
File exists Run if the file exists.
The file is expanded using the Token Macro Plugin. If the file is
relative, then it is relative to the Base directory. If the file is
absolute, then it will be tested on the Node that contains the Base
directory (the master for $JENKINS_HOME and Artifacts dir).
Files match Run if one or more files match the selectors.
Separate multiple includes or excludes patterns with a comma. e.g.
Includes "target/site/**/*.html,target/site/images/" Excludes
"**/*.gif" If no includes pattern is configured, then the pattern
"**" will be used, which matches all files in the directory and all
sub directories. The includes and excludes are Ant Patterns.
I am using Editable Email plugin in Jenkins to attach a file with the email. The problem is that the plugin is unable to find the file to attach.
My file structure is like this -
ReportDirectory
workspace
ReportDirectory contains the report which I want to attach. I believe that the base directory for the plugin is the workspace. So I am giving the attachment location as
../ReportDirectory/DemoReport.html.
I have also tried
ReportDirectory/DemoReport.html
and many more options.
Am I doing something wrong?
I figured it out.
The Editable Email plugin uses the Ant File Syntax for locating the attachment. When I took at the documentation for Ant File Syntax ( http://ant.apache.org/manual/dirtasks.html ), it says that
In general, patterns are considered relative paths, relative to a task dependent base directory (the dir attribute in the case of ). Only files found below that base directory are considered. So while a pattern like ../foo.java is possible, it will not match anything when applied since the base directory's parent is never scanned for files.
Since the base directory in this case is the "workspace" and my directory "ReportDirectory" is not located in it so the Ant is not able to access it.
Two solutions exist:
Move the "Report Directory" somewhere in "workspace". I did not prefer this because I did not want to mess up the workspace.
Once the report has been created in "ReportDirectory", use your Ant\MSBuild script to copy it temporarily in the "workspace" and then the Email plugin shall be able to access it by something like **/Report.html or something.
#Amey - thanks for your efforts though :)
Another solution is create a symbolic link from $JENKINS_HOME/jobs/workspace/$workspace_name to the path with your $workspace_name. This way worked for me.
ReportDirectory/DemoReport.html
is the correct way to do it.
Please keep in mind that the path to the file and the file name is case sensitive so I assume your entering the correct name.
One more thing is to check is that the report is actually created and is located at the path mentioned by you.
Another thing you could try
ReportDirectory/*
Jenkins will use the directory available in its workspace.
You can send multiple attachments as below.
reportFolder/html/index.html, screenShotsFolder/screenShots/*.jpg
Simple answer:
Copy your file into the workspace(into your job directory), then under Attachment, just give the file name without any quotation or anything. This will automatically tell Jenkins to pick up your file. That's it!
Pls don't confuse yourself after seeing all the configurations.
I'm working on a personal project for learning purposes in XNA. I've read online that using the content pipeline requires people to have the xna runtime installed. So i've decided to load files using Texture2D.FromStream.
Everything is fine when I'm running the project from visual c#, but when I publish the project and run it, it crashed immediatly. I'm not sure if there is a way to see more info on the crash, but I assume not. I'm thinking it's down to not using the content pipeline.
When I look inside the application files for the published project I only see .xnb files. and no raw .png and .xml files that I'm using.
I tried to place the files in there manually but that didn't work aswell.
The files are all in the "Projectname\bin\x86\Debug\Content" folder.
Anyone has any idea?
edit
I have just rewritten my contentmanager so it uses the content pipeline, and the published project now works fine on my pc. So I have to figure out a way to get it to work without the content pipeline
if you work with Texture2D.FromStream, you have to care about two facts:
You have to change some resource's properties:
Compile action: None
Copy to result folder: Always
This way the xnb won't be builded and you will get your resources instead
You have to set the appropiate path, now you have not "bin\Debug" in your path.
As #Blau mentions, changing the image's properties will fix your problem. As you can see, the FromStream method is fully supported on the framework on all platforms now:
http://blogs.msdn.com/b/shawnhar/archive/2010/05/10/image-codecs-in-xna-game-studio-4-0.aspx.
As far as seeing errors ... you can always put a try catch around the statement that you think is throwing the error and then write out the error text to the screen so you can see it. Something like
try
{
//The offending code
}
catch(Exception ex)
{
WriteError(ex.Message);
}