Nunit: Can you open multiple projects in unit using a bat file? - nunit

I currently used a batch file which runs a project of mine which is simlar to the following:
nunit-gui.exe nunit.tests.csproj
Can it be setup to use two or more project files? I've tried adding quote marks and seperating the project names with commas and semi-colons but no luck.
Will I just have to create a master solution with all tests in and send that through as the parameter instead?

It is better to use NUnit project files. In the "config" section you can specify any number of assemblies to load.

Are you trying to run these by running a batch file? If so I think that nunit-console.exe or nunit-console-86.exe
Then to run multiple items its normally
nunit-console assem1.dll assem2.dll assem3.dll
I haven't tried it with project files but should work the same
http://www.nunit.org/index.php?p=consoleCommandLine&r=2.5.2

Related

Using Microsoft.Data.SqlClient in PowerShell

I would like to use the Microsoft.Data.SqlClient namespace/ objects in a PowerShell script.
Two (click1, click2) Github posts provide a way to load the correct dll's, but the solutions don't seem to work anymore.
E.g. result of the first solution while copying the next files:
(Packages copied from .nuget/packages folder)
Microsoft.Data.SqlClient.dll
Microsoft.Data.SqlClient.SNI.x64.dll
Microsoft.Identity.Client.dll
Result: Could not load file or assembly 'System.Runtime, Version=6.0.0.0'
In addition, I've tried to create a Dummy Console App -> Added the Microsoft.Data.SqlClient Nuget package -> built the project and copied all dll's to the same folder as the PS script.
As soon as I start the script (using the 'Add-Type -Path' construction), it results in errors, such as 'couldn't load file or assembly - wrong version...' (this is strange, because the folder contains all dll's...)
Could you provide an alternative solution/ steps in order to use the described package in a PS script?

How to use Pentaho Spoon to rename files that do not have an extension

I am new to using Pentaho Spoon. I have about 100 text files in a folder, none of which have file extensions. I have found that if I create a job and move a file, one at a time, that I can simply rename that file, adding a .txt extension to the end. What I'd like to do is create a job that goes through and renames each file and adds the .txt extension. I've tried using the regex, but can't seem to get it to work because there's no file extension.
Any help would be greatly appreciated.
It's a pretty straightforward solution but you need to use a Transformation, as Job steps won't do it, ok?
You need the following steps:
Get File Names: just add your folder and the RegExp ".*" (without the double quotes), so everything is listed. Check if it's ok with "Show filename(s)..." button.
Modified Java Script Value: declare a new_filename var concatenating the desired extension. Remember to click "Get Variables" after adding the script to output the new field.
var new_filename = filename + '.txt';
Process Files: select Operation = Move and filename/new_filename as your source/target filenames.
That's it!
Renaming a group of files is one thing I wouldn't use Kettle for. Why not let the shell do what the shell does best?
rem example for Windows CMD shell
ren absolute-path-to-folder\*. *.txt
This can be done using a Shell job entry, if you find reason to do it in Kettle at all.
I've seen "just use a shell script" answers for this before. Works great if you can guarantee you're Kettle server is on the same OS as the developer workstation. I'm in an environment where the Dev/Spoon instance is Windows, but the Prod/Kettle environment is Linux, so you can't write one script file to rule them all.
As for "Why on earth would you do this?", my scenario is an integration scenario. We're using Pentaho for Data Integration, but a different tool for Enterprise Integration. I want a Pentaho Job to produce an output file, and I want my Enterprise Integration tool to pick up the file and do something with it, but not before Pentaho is done writing the file. Renaming helps avoid a race condition when the Enterprise Integration solution recognizes the file is there, but Pentaho isn't done writing it yet.
If I could rename a set of files, for example change from test..csv.processing to test..csv, then Pentaho would create the file initially with the .processing extension, and then remove the extension once it's done. The Enterprise Integration solution that's looking for test.*.csv won't start processing the file until Pentaho renames it. Bingo, no race condition.

How to run tests under a specific folder with NUnit 3?

I have a lot of tests (classes) and they are placed to different folders.
It looks like this:
I want to run all the tests under a specific folder including all sub-folders.
Please help me to do it using NUnit 3 console commands.
Here is a manual for this https://github.com/nunit/docs/wiki/Test-Selection-Language
The thing is: if I use: --where "test==LottoSend.com.TestCases.BackOffice" then it runs only tests under sub-folders in BackOffice folder (CMS, Packages, Raffle, etc.) but it doesn't run tests placed directly in "BackOffice" folder (such as BlackListTests.cs etc.)
Maybe I need to use another parameter for this?
NUnit knows nothing about the location of your source code. It doesn't look need or look at source code at all, but at the compiled test assembly.
If it's running the tests in the BackOffice folder, it's because they are all defined in the namespace "LottoSend.com.TestCases.BackOffice" - not because of what folder they are in.
What namespaces are used in your subfolders? Common practice would put the code under CMS in "LottoSend.com.TestCases.BackOffice.CMS" but it's up to you how you write the code.
So your choice is to either change the namespaces to match the folders or move the code to a folder that matches the namespace.

Environment.CurrentDirectory with NUnit GUI differs to the TeamCity value, how can I sync them?

As above really, I have some integration tests that use files from a relative file path. To help picture it here is the file structure:
/Dependencies
/VideoTests/bin/release/video.dll
/SearchTests/bin/release/search.dll
/OtherProjects
The GUI is running the tests from the root, however when TeamCity runs the tests it is running the tests from each test dlls bin directory. Now I don't mind which one I can get to follow the other but I do need them to be the same otherwise my relative paths just won't work!
Any ideas?
P.S. Using TeamCity 5.0 and NUnit 2.5.
You probably don't want to rely on CurrentDirectory. I'd suggest reading the doc, but the main point you'll want to take away is that the CurrentDirectory is where the .exe was started from: it could be any path in the system. For example, let's assume your users add your .exe (or whatever .exe uses your DLLs) to their path. They could then navigate to c:\foo\bar and start the .exe from there, which would set the CurrentDirectory to "C:\foo\bar" and you may not be able to deal with that.
I think it would be preferable for you to rework whatever you're doing so you don't rely on CurrentDirectory. What problems are you encountering by relying on CurrentDirectory right now?
Have you made sure that both TeamCity and NUnit are using the same working directory when starting the application?
And if they aren't, you could adjust the current directory in the test code.

Is there a way to specify more than one app config file in one nunit project file?

I have a collection of unit test that I need to all run from one command line call. One of the assemblies uses a different config file than the rest of the assemblies. Is there a way to specify more than one app config file in one nunit project file?
Not in a project file, but you can specify a config file per assembly (e.g. TestAssembly1.dll.config)
I would say when you script running your tests, you rename the right app.config to replace the other one so that when your tests start the right app.config is loaded. Let me know if you need an example of how to do that.