How can I declare that the "root" folder for all deployment items are the .sln dir?
Seems like I work really hard with relative paths of deployment items
[TestMethod]
[DeploymentItem(#"..\..\..\MyTestFilesFolder\myFile.xml")]
public void Test_bla{}
Given that "MyTestFilesFolder" is near my .sln file (solution folder) I'd like to have
[TestMethod]
[DeploymentItem(#"MyTestFilesFolder\myFile.xml")]
public void Test_bla{}
How can this be achieved with tests of vs2013?
It seems you are not deploying the xml files with your unit tests. Go to the properties of the xml files and set the build action and to content and copy to output directory to copy always. Now the files are deployed to your test directory.
Related
I have a following project structure
bin
start.sh
db
liquibase_scripts
...
schema.json
main
java
...
test
resources
liquibase_scripts
...
schema.json
So than I build my project, folder db with liquibase scripts added to distributive.
In unit tests I use H2 database and want to load schema from db/liquibase. I create bean
#Bean
public SpringLiquibase springLiquibase() {
SpringLiquibase springLiquibase = new SpringLiquibase();
springLiquibase.setDataSource(dataSource());
springLiquibase.setChangeLog("classpath:/liquibase/sam.json");
return springLiquibase;
}
The problem is that method setChangeLog look at resource folder in test folder.
So to solve the problem I copied all liquibase scripts to the test/resources directory.
But this is not ok becouse now I have 2 copies of scripts in different folders.
Is there a way to force springLiquibase.setChangeLog find scripts in any folder not only in test/resources?
In Maven build configuration you can define testResources, which may be directories and files. It looks like this:
<build>
<testResources>
<testResource>
<directory>${project.basedir}/db/liquibase_scripts</directory>
</testResource>
</testResources>
</build>
With such configuration Maven copies the files into the target/test-classes directory. Thanks to that those files can be used as test resources in the code, but there's no duplication in the project files.
Im using such configuration (Liquibase + testResources) in one of my projects. To better reproduce your problem, I've created a separate branch, where you can find the configuration described above - see: this commit diff. All test pass after the change.
How to create an executable jar project for Geb-Groovy based project in eclipse.
The following is the directory structure:
the pages package contains the groovy files
the testclasses package contains the test cases groovy files
the utils package contains the groovy files to read data of excel sheets.
Detailed instructions for creating the jar file would be highly appreciated.
If the project you are working with is a gradle project I would recommend looking at a task called "shadowJar" https://github.com/johnrengelman/shadow
in build.gradle would have something like this:
apply plugin: "com.github.johnrengelman.shadow"
mainClassName = '<Name of your Main Class>' //This will act as the jar's main point of entry the 'Main' method found in this class will be executed when the jar is executed
shadowJar {
manifest {
attributes 'Main-Class': mainClassName
}
}
Then you simply make a run the shadowJar task and a jar file is generated in your build folder. It should also contain all your dependencies as well.
I have a Teamproject which has only one solution, which contains a MVC web application and a MS Test project (Unit tests).
The Unit test project references the web app.
MyWebApp
MyWebApp.Tests
I can see all files being copied to the Build_SourceDirectory!
But I can only see the MyWebApp.Tests being copied to the Drop folder!?
My Visual Studio buil step:
My Copy Files build step:
Question:
Why does "Copy Files" build step only copy the artifacts of the test project and not the web app, which is in the same solution?
Here is the log file
**\bin\$(BuildConfiguration)\** means you want to copy the files in any sub-folder under bin\$(BuildConfiguration), but MyWebApp's outputs are in bin folder, not under bin\$(BuildConfiguration), so they are not copied.
Specify the Contents in Copy Files task to **\bin\**, you'll get both outputs for MyWebApp and MyWebApp.Tests:
An addition to the provided answer.
With the OOTB minimatch filter:
**\bin\$(BuildConfiguration)\**
you copy everything beneath the BuildConfiguration folder (Release/Debug/etc).
Web apps don't have a Debug/Release folder by default, only one bin folder. That's the reason why anything was copied to the drop folder.
So I had to include some content filters to include/exclude the files/folders I want to copy/don't want to copy, like this:
For exclusions you can use negated filters using the ! sign.
I have my folder structured like:
backend
|-Process1
|-Process2
|-app
|-config
|-controllers
|-models
public
|-css
|-js
Where should I put my unit tests folder?
For node projects, it's common to have a tests folder in the top level. For example, for my projects I usually have these folders:
bin (for bins)
lib (for my node.js library files)
test (for tests)
config (for config files, if necessary)
public or static (for static assets, if necessary)
node_modules (where npm-installed modules end up going)
For the most part it's not too critical how you organize the code as long as it's organized and has obvious entry points. Basically, you should be able to type "npm test" and have it work by reading the command from the package.json.
I want to add an deployment item to my test. As far as I understood up until now, the path is relative to the solution. I want the path to be relative to the project. Otherwise, the project can't be used in multiple solutions.
How can I configure the deployment Item to be relative to a project dependent variable?
I was hoping for something like: [DeploymentItem(#"$(ProjectDir)..\..\bin\$(Configuration)")] but I don't find any documentation and it does not seem to work.
I just did a small test. Just plain wizard code and one deployment item:
[TestMethod]
[DeploymentItem("stdafx.cpp")]
void TestMethod1()
{
Assert::Fail();
};
and the trx file shows the following line:
Warning: Test Run deployment issue: Failed to get the file for deployment item 'stdafx.cpp' specified by the test 'TestProject1.UnitTest1.TestMethod1': System.IO.FileNotFoundException: Could not find file 'd:\Development\Projects\deploymentItemTest\stdafx.cpp'.
System.IO.FileNotFoundException: Could not find file 'd:\Development\Projects\deploymentItemTest\stdafx.cpp'.
File name: 'd:\Development\Projects\deploymentItemTest\stdafx.cpp'
which means that "stdafx.cpp" is searched relative to the solution directory (which is in ...\depoymentItemTest) and not the project directory (which is in ...\depolymentItemTest\TestProject1)
I know this is an old question, but my answer may help others.
I was able to solve this problem with two simple steps:
Create the following build event on the test project:
xcopy /I /S /Y "$(TargetDir)*.*" "$(SolutionDir)\bin"
This will copy all the contents (including sub-directories) of the project folder to a folder "bin" relative to the solution.
Add the following DeploymentItem to the test class:
[DeploymentItem ("bin")]
This will copy all the bin contentes to the test folder
This mechanism may be refined (if required) with additional filters both in the build event and the DeploymentItem
Let the test setup copy the file to Environment.CurrentDirectory.