vstest.console.exe with ClassName as /testcasefilter - vstest.console

I am looking for executing the unit test by ClassName using vstes.console.exe, any help
I tried like
/TestCaseFilter:"ClassName=ProgressTests"
but that throws this error:
Error: No tests matched the filter because it contains one or more
properties that are not valid (ClassName). Specify filter expression
containing valid properties (TestCategory, Priority,
FullyQualifiedName, Name) and try again.
Thanks

You can run the tests by specifying the fully qualified class name:
vstest.console MyBusinessDomain.Tests.dll /testcasefilter:FullyQualifiedName~MyBusinessDomain.Tests.Shopping.Cart
where:
MyBusinessDomain.Tests.dll is the test dll
MyBusinessDomain.Tests.Shopping.Cart is the fully qualified class name
Or you can run the tests classes by namespace:
vstest.console MyBusinessDomain.Tests.dll /testcasefilter:FullyQualifiedName~MyBusinessDomain.Tests.Shopping
This command will run all the tests under MyBusinessDomain.Tests.Shopping namespace.
NOTE: FYI, vstest.console is newer than mstest and is preferred for running via the command line. It can be added to the environment path with this location(for VS2015) :
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow

According to https://blogs.msdn.microsoft.com/vikramagrawal/2012/07/23/running-selective-unit-tests-in-vs-2012-rc-using-testcasefilter/ - "ClassName is only valid for unit tests for Windows store apps, currently not available for classic MSTest" although that blog post is from years ago now though.
You could just use the FullyQualifiedName filter type as in /testcasefilter:FullyQualifiedName~NameSpace.Class

The tilda ~ means "contains", so if Foobar is the name of your class:
vstest.console bin\Debug\MyTests.dll /TestCaseFilter:FullyQualifiedName~Foobar
See https://msdn.microsoft.com/en-us/library/jj155800.aspx

Related

DBT - [WARNING]: Did not find matching node for patch

I keep getting the error below when I use dbt run - I can't find anything on why this error occurs or how to fix it within the dbt documentation.
[WARNING]: Did not find matching node for patch with name 'vGenericView' in the 'models' section of file 'models\generic_schema\schema.sql'
did you by chance recently upgrade to dbt 1.0.0? If so, this means that you have a model, vGenericView defined in a schema.yml but you don't have a vGenericView.sql model file to which it corresponds.
If all views and tables defined in schema are 1 to 1 with model files then try to run dbt clean and test or run afterward.
Not sure what happened to my project, but ran into frustration looking for missing and/or misspelled files when it was just leftovers from different compiled files not cleaned out. Previously moved views around to different schemas and renamed others.
So the mistake is here in the naming:
The model name in the models.yml file should for example be: employees
And the sql file should be named: employees.sql
So your models.yml will look like:
version: 2
models:
- name: employees
description: "View of employees"
And there must be a model with file name: employees.sql
One case when this will happen is if you have the same data source defined in two different schema.yml file (or whatever you call it)

Powershell v2 - The correct way to load an assembly as part of a module

I have a Powershell (v2.0) script that I am working on.
One of the first things it does is loads a Module (runMySQLQuery.psm1) which includes (amongst other bits) a function to connect to a MySQL Database.
Import-Module runMySQLQuery.psm1
However, this requires that an assembly MySQL.Data.DLL is loaded in order for this to work.
If I place the line:
[void][system.reflection.Assembly]::LoadFrom("C:\PowerShell\modules\runMySQLQuery\MySql.Data.dll")
at the top of my script (separate to the Import-Module entry), then the whole thing works fine.
But I want to be able to load this assembly at the same time as the module, so that I don't have to worry about forgetting to including the assembly each time I use this module.
I tried placing it at the top of the .psm1 file, but that didn't work.
I then added it to my manifest file as:
RequiredAssemblies = #("C:\PowerShell\modules\runMySQLQuery\MySql.Data.dll")
This also didn't work.
Am I missing something here, is there a proper way to include assemblies as part of a module?
n.b. the error I get when it hasn't loaded properly is:
You cannot call a method on a null-valued expression
Can you just try to assign a varialbe a the beginig of you module :
$dumy = [system.reflection.Assembly]::LoadFrom("C:\PowerShell\modules\runMySQLQuery\MySql.Data.dll")

How can I custom AspectJ aop.xml location?

I have the same question related to this:
aop.xml name and location?
In the answers, it says:
use the system property:
-D org.aspectj.weaver.loadtime.configuration=META-INF/myaop.xml
What does "use the system property" mean?
create a aop.properties file?
Or, write in the vm option?
AFAIK there is no such thing as aop.properties. Have you just made this up? The hint means you should specify the property as a JVM command line parameter like this, if the given path can be resolved as a Java resource path/URL:
java ... -Dorg.aspectj.weaver.loadtime.configuration=META-INF/myaop.xml ...
If you explicitly want to point to the file system, you have to precede the path by file:, e.g.
java ... -Dorg.aspectj.weaver.loadtime.configuration=file:META-INF/myaop.xml ...
or
java ... -Dorg.aspectj.weaver.loadtime.configuration=file:c:\my\path\META-INF\myaop.xml ...
Attention: no white space between -D and the property name!
Update:
What does "use the system property" mean?
Your favourite search engine will lead you to pages like:
Oracle Java tutorial
System Javadoc, specifically methods
getProperties(),
getProperty(String),
getProperty(String, String),
setProperties(Properties),
setProperty(String, String),
clearProperty()

How do I pass MSBuild arguments from the build definition to a MSBuild workflow Activity

I've defined an MSBuild activity in a TFS Workflow template, but currently I have to hard code the 'property' command line arguments directly into the template.
I'd like to be able to specify the arguments in the build definition, via the advanced setting, 'MSBuild Arguments'
I can see that I may have to build up the command line with string replace/concat, as mentioned here, but I can't see what I need to put, maybe something like this:
This is what the default MsBuild task uses:
String.Format("/p:SkipInvalidConfigurations=true {0}", MSBuildArguments)
You can change the MSBuildArguments variable in the build process template in multiple steps. For example, I added a Run Architecture Validation property to the process template and then edited the workflow to simply append /ValidateArchitecture=true to the MSBuildArguments before they're being passed to the MsBuild activity.
<If Condition="[PerformArchitectureValidation]" DisplayName="Configure Architecture Validation MSBuild Arguments">
<If.Then>
<Assign>
<Assign.To>
<OutArgument x:TypeArguments="x:String">[MSBuildArguments]</OutArgument>
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="x:String">[MSBuildArguments + " /p:ValidateArchitecture=true"]</InArgument>
</Assign.Value>
</Assign>
</If.Then>
</If>
The PerformArchitectureValidation variable is defined as a Property on the Build Process Template level of type Boolean.
Update: Wrote a blogpost that explains this with steps and screenshots

MsTest, DataSourceAttribute - how to get it working with a runtime generated file?

for some test I need to run a data driven test with a configuration that is generated (via reflection) in the ClassInitialize method (by using reflection). I tried out everything, but I just can not get the data source properly set up.
The test takes a list of classes in a csv file (one line per class) and then will test that the mappings to the database work out well (i.e. try to get one item from the database for every entity, which will throw an exception when the table structure does not match).
The testmethod is:
[DataSource(
"Microsoft.VisualStudio.TestTools.DataSource.CSV",
"|DataDirectory|\\EntityMappingsTests.Types.csv",
"EntityMappingsTests.Types#csv",
DataAccessMethod.Sequential)
]
[TestMethod()]
public void TestMappings () {
Obviously the file is EntityMappingsTests.Types.csv. It should be in the DataDirectory.
Now, in the Initialize method (marked with ClassInitialize) I put that together and then try to write it.
WHERE should I write it to? WHERE IS THE DataDirectory?
I tried:
File.WriteAllText(context.TestDeploymentDir + "\\EntityMappingsTests.Types.csv", types.ToString());
File.WriteAllText("EntityMappingsTests.Types.csv", types.ToString());
Both result in "the unit test adapter failed to connect to the data source or read the data". More exact:
Error details: The Microsoft Jet database engine could not find the
object 'EntityMappingsTests.Types.csv'. Make sure the object exists
and that you spell its name and the path name correctly.
So where should I put that file?
I also tried just writing it to the current directory and taking out the DataDirectory part - same result. Sadly, there is limited debugging support here.
Please use the ProcessMonitor tool from technet.microsoft.com/en-us/sysinternals/bb896645. Put a filter on MSTest.exe or the associate qtagent32.exe and find out what locations it is trying to load from and at what point in time in the test loading process. Then please provide an update on those details here .
After you add the CSV file to your VS project, you need to open the properties for it. Set the Property "Copy To Output Directory" to "Copy Always". The DataDirectory defaults to the location of the compiled executable, which runs from the output directory so it will find it there.