I have a test case that looks like:
namespace UnitTests
[<TestFixture>]
module ValidatorTests =
[<Test>]
let VerifyBasicFunctionality () =
Assert.That(bool)
Assert.That(bool)
and when I try to run it in the Visual Stuido test explorer, nothing happens (even with the Test Adapter for NUnit 3) and just says "Successful Build" and no tests discovered. Then when I run from the commandline with the nunit-console runner (tried with v.1, v.2, v.4) I get something different:
$ nunit-console4 bin/Release/UnitTests.dll
NUnit version 2.4.8
Copyright (C) 2002-2007 Charlie Poole.
Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
Copyright (C) 2000-2002 Philip Craig.
All Rights Reserved.
Runtime Environment -
OS Version: Unix 15.6.0.0
CLR Version: 4.0.30319.42000 ( 4.4.2 (Stable 4.4.2.11/f72fe45 Thu Aug 11 06:03:25 BST 2016) )
.N.N.N
Tests run: 0, Failures: 0, Not run: 3, Time: 0.011 seconds
When I run this with the -xmlConsole flag, I get this:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!--This file represents the results of running a test suite-->
<test-results name="bin/Release/UnitTests.dll" total="0" failures="0" not-run="3" date="2016-09-08" time="10:26:00">
<environment nunit-version="2.4.8.0" clr-version="4.0.30319.42000" os-version="Unix 15.6.0.0" platform="Unix" cwd="/SOMEUSER/SOMEPATH/UnitTests" machine-name="gmaini-m.jet.local" user="SOMEUSER" user-domain="SOMELOCALBOX" />
<culture-info current-culture="en-US" current-uiculture="en-US" />
<test-suite name="bin/Release/UnitTests.dll" success="True" time="0.010" asserts="0">
<results>
<test-suite name="UnitTests" success="True" time="0.008" asserts="0">
<results>
<test-suite name="ValidatorTests" success="True" time="0.001" asserts="0">
<results>
<test-case name="UnitTests.ValidatorTests.VerifyBasicFunctionality" executed="False">
<reason>
<message><![CDATA[UnitTests.ValidatorTests is an abstract class]]></message>
</reason>
</test-case>
<test-case name="UnitTests.ValidatorTests.VerifyBasicOtherFunctionality" executed="False">
<reason>
<message><![CDATA[UnitTests.ValidatorTests is an abstract class]]></message>
</reason>
</test-case>
<test-case name="UnitTests.ValidatorTests.VerifyBasicSomeFunctionality" executed="False">
<reason>
<message><![CDATA[UnitTests.ValidatorTests is an abstract class]]></message>
</reason>
</test-case>
</results>
</test-suite>
</results>
</test-suite>
</results>
Any idea why it seems to discover the tests, I can dot access them with -run="Namespace.Module.Function" and talk about the fixture with -fixture="Namespace" but it won't run them? Is the UnitTests.ValidatorTests.VerifyBasicFunctionality is an abstract class a hint that there is some C# interop problem?
Thanks for your time :)
This fix was:
namespace UnitTests
[<TestFixtureAttribute>]
type ValidatorTests () =
[<Test>]
member __.VerifyBasicFunctionality() =
Assert.That(bool)
Assert.That(bool)
Basically, making this object oriented. So my hypothesis was correct.
Related
my project solution is based on Sitecore Helix Visual Studio Templates by Ander's Laub. Im trying to write Unit tests using XUnit, but none of the tests are running and not even failing.
For test projects, I have tried using Project based on Class Library(.NET Framework), Projects based on Sitecore Helix Visual Studio Templates by Ander's Laub.
Packages used:
XUnit(2.4.1)
XUnit.Runner.VisualStudio(2.4.3)
XUnit.Runner.Console(2.4.1)
Framework: .NET 4.8
Visual Studio 2019: v16.8.5
The output im getting:
Since Im not able to post images, here is the Text Explorer details:
Group Summary
Linde.Foundation.SitecoreExtensions.Tests
Tests in group: 1
Outcomes
1 Not Run
DemoTests.cs
public class DemoTests
{
[Fact]
public void DemoTestForPassingOnly()
{
double expected = 5;
double actual = 4;
Assert.Equal(expected, actual);
}
}
Test Run Output window:
ProjectData: Could not find project with GUID 09fe023c-998c-4a4c-a896-bc27884e7aaf
ProjectData: Could not find project with GUID 09fe023c-998c-4a4c-a896-bc27884e7aaf
---------- Starting test run ----------
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.3+1b45f5407b (64-bit Desktop .NET 4.0.30319.42000)
No test matches the given testcase filter `FullyQualifiedName=Linde.Foundation.SitecoreExtensions.Tests.DemoTests.DemoTestForPassingOnly` in C:\SourceTree\lindemh-sitecore\bin\Debug\Linde.Foundation.SitecoreExtensions.Tests.dll
========== Test run finished: 0 Tests run in 1.3 sec (0 Passed, 0 Failed, 0 Skipped) ==========
I have tried building a separate Console Application with Tests project to make sure whether this is a Visual Studio Issue, but it is running/failing/passing inside the console application, but not inside the Sitecore Project.
Do I have to configure the solution differently in order for the Tests to run successfully?
For simple unit tests using xunit I only have those references in my package :
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="xunit" version="2.4.1" targetFramework="net462" />
<package id="xunit.abstractions" version="2.0.3" targetFramework="net462" />
<package id="xunit.analyzers" version="0.10.0" targetFramework="net462" />
<package id="xunit.assert" version="2.4.1" targetFramework="net462" />
<package id="xunit.core" version="2.4.1" targetFramework="net462" />
<package id="xunit.extensibility.core" version="2.4.1" targetFramework="net462" />
<package id="xunit.extensibility.execution" version="2.4.1" targetFramework="net462" />
<package id="xunit.runner.console" version="2.4.1" targetFramework="net462" developmentDependency="true" />
<package id="xunit.runner.visualstudio" version="2.4.1" targetFramework="net462" developmentDependency="true" />
</packages>
So I believe the XUnit.Runner.VisualStudio(2.4.3) should be 2.4.1.
Then a simple test could look like that
using aProject.Foundation.Utilities.Extensions;
using Xunit;
namespace aProject.Foundation.Utilities.Tests
{
public class ExtensionsTests
{
public class StringExtensionTests
{
[Theory]
[InlineData("some awesome string")]
[InlineData(" some awesome string ")]
public void Should_returnValidSlug_When_passingStringWithSpaces(string name)
{
Assert.Equal("some-awesome-string", name.ToSlug());
}
}
}
}
Basically I am exploring IVY, to version my binary artifacts and how to do version control automatically using ivy. I found that publish, pubrevision could help me out.
Hence I am trying to publish my jar through IVY. However I am getting below error and build failed.
impossible to publish artifacts for lib#MyService;working#Localhost java.io.IOException: missing artifact lib#MyService;1.0!MyService.jar
Please find my ivy.xml
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0" xmlns:m="http://ant.apache.org/ivy/maven">
<info organisation="lib" module="MyService" />
<configurations defaultconfmapping="default->default;sources->sources;test->default">
<conf name="sources" transitive="false" visibility="private" />
<conf name="test" transitive="false" visibility="private" />
<conf name="default" transitive="false" />
</configurations>
<publications>
<artifact name="MyService" type="jar"/>
</publications>
<dependencies defaultconf="default">
<dependency org="lib" name="commons-logging-1.1" rev="1.1" />
<dependency org="lib" name="commons-collections-3.2" rev="3.2" />
<dependency org="lib" name="commons-beanutils" rev="1.7.0" conf="default" />
</dependencies>
</ivy-module>
Publish task : Note: dist will resolve my dependency and compile and jar
build.xml
<target name="publish" depends="dist">
<ivy:publish resolver="local" pubrevision="1.0" module="MyService" status="release" forcedeliver="true" update="true">
<artifacts pattern="publish/[organisation]-[artifact].[ext]"/>
</ivy:publish>
</target>
MyService.jar is being created in my build folder.
Can you please assist me, what is wrong with my code. I am pretty new to IVY. So any inputs will be appreciated very much.
Thanks.
When i build my project in TFS 2015, I have set up to run all Unit tests/code coverage. The tests run and all of them pass. The issue i am having is that the results don't show up at the summary of the build or any where. Any reason why not showing up?
I looked at the logs and i am getting this warning:
Results File:
C:\BuildAgent_work\1\TestResults\serverName$_serverName 2015-12-03
15_56_33.trx
Total tests: 533. Passed: 533.
Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 29.5985 Seconds
Publishing Test Results...
##[warning]Invalid results file.
Please make sure the Test Result Format field in the task matches the
result format of the file:
C:\BuildAgent_work\1\TestResults\serverName$_serverName 2015-12-03
15_56_33.trx
I looked at the file
serverName$_serverName 2015-12-03 15_56_33.trx`
<?xml version="1.0" encoding="UTF-8"?>
<TestRun id="730b84f3-e06c-4d30-8994-15aa6ff385df" name="serverName$#serverName 2015-12-03 15:56:33" runUser="NT AUTHORITY\NETWORK SERVICE" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<Times creation="2015-12-03T15:56:33.2204061-05:00" queuing="2015-12-03T15:56:33.2204061-05:00" start="2015-12-03T15:56:33.2204061-05:00" finish="2015-12-03T15:57:01.4723683-05:00" />
<TestSettings name="default" id="d53ac855-fee0-4c64-9372-227e08990a04">
<Execution>
<TestTypeSpecific />
</Execution>
<Deployment runDeploymentRoot="serverName$_serverName 2015-12-03 15_56_33" />
<Properties />
</TestSettings>
<TestLists>
<TestList name="Results Not in a List" id="8c84fa94-04c1-424b-9868-57a2d4851a1d" />
<TestList name="All Loaded Results" id="19431567-8539-422a-85d7-44ee4e166bda" />
</TestLists>
<ResultSummary outcome="Completed">
<Counters total="0" executed="0" passed="0" failed="0" error="0" timeout="0" aborted="0" inconclusive="0" passedButRunAborted="0" notRunnable="0" notExecuted="0" disconnected="0" warning="0" completed="0" inProgress="0" pending="0" />
<Output>
<StdOut>NUnit 1.2.0.0 executing tests is startedLoading tests from C:\BuildAgent\_work\1\a\App.Tests.dllRun started: C:\BuildAgent\_work\1\a\App.Tests.dllLoading tests from C:\BuildAgent\_work\1\a\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dllRun started: C:\BuildAgent\_work\1\a\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dllNUnit 1.2.0.0 executing tests is finished</StdOut>
</Output>
<RunInfos>
<RunInfo computerName="serverName" outcome="Warning" timestamp="2015-12-03T15:56:31.8163881-05:00">
<Text>Diagnostic data adapter message: Could not find diagnostic data adapter of type 'Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector' and Uri 'datacollector://microsoft/CodeCoverage/2.0'.</Text>
</RunInfo>
<RunInfo computerName="serverName" outcome="Warning" timestamp="2015-12-03T15:56:32.8460013-05:00">
<Text>Unable to create DiaSession for C:\BuildAgent\_work\1\a\App.Tests.dll
No source location data will be available for this assembly.</Text>
</RunInfo>
<RunInfo computerName="serverName" outcome="Warning" timestamp="2015-12-03T15:57:01.1759645-05:00">
<Text>System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain. This can happen if the test(s) started a thread but did not stop it. Make sure that all the threads started by the test(s) are stopped before completion.</Text>
</RunInfo>
</RunInfos>
</ResultSummary>
</TestRun>
My issue was with the Visual Studio in the build server. Once i updated Visual Studio from 2013 to 2015 in the build server everything worked fine.
I have a ugly Teamcity build configuration using MSBuild. It executes custom application (test runner), which is using custom messaging to report test results to teamcity.
##teamcity[testStarted name='test1']
##teamcity[testFailed name='test1' message='failure message' details='message and stack trace']
Which show in teamcity in build overview and tests tab.
Teamcity recognizes failed tests and if any test fails, it marks the build as failed:
http://i.stack.imgur.com/Qz9UT.png
Later in the MSBuild target I would like to label cvs based on the test results.
Is there a way to get the build status (if it is failed, hanging, warning) as a property? something like %build.status%? The format does not matter - if its a string or number.
PS: I know that best solution to my problem would be to modify the application to return non-zero exit code if test fail.
TeamCty does not seem to expose this directly, but the status can be acquired using the REST api. Here is an example using curl; but you could also uwe PowserShell's Invoke-RestMethod for instance.
Here's the msbuild script that casues test failure I used for testing:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Test">
<Message Importance="high" Text="##teamcity[testStarted name='test1']" />
<Message Importance="high" Text="##teamcity[testFailed name='test1' message='failure message' details='message and stack trace']" />
</Target>
</Project>
Then the script that gets the current build's status, dumps it to a file, reads the file into an msbuild item and then uses regex to get the status out of it. You just have it to supply the tc_user and tc_password properties (or allow guest access) and change the url to match your server.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="GetBuildStatus">
<Target Name="RunCurl">
<PropertyGroup>
<MyTempFile>curl_out</MyTempFile>
</PropertyGroup>
<Exec Command="curl http://localhost/httpAuth/app/rest/builds/id:$(teamcity_build_id) -basic -u $(tc_user):$(tc_password) > $(MyTempFile)"/>
<ReadLinesFromFile File="$(MyTempFile)">
<Output TaskParameter="Lines" ItemName="CurlOutput"/>
</ReadLinesFromFile>
<Delete Files="$(MyTempFile)"/>
</Target>
<Target Name="GetBuildStatus" DependsOnTargets="RunCurl">
<PropertyGroup>
<CurlOutputFull>#(CurlOutput)</CurlOutputFull>
<BuildStatus>$([System.Text.RegularExpressions.Regex]::Match($(CurlOutputFull), `status="(\w*)"`).Groups[ 1 ].Value)</BuildStatus>
</PropertyGroup>
<Message Text="BuildStatus = $(BuildStatus)"/>
</Target>
</Project>
This prints:
BuildStatus = FAILURE
we try to use spring with metro stack to implement webservices.
The setup seems to be ok, but we get an error in the applicationContext.xml
cvc-complex-type.2.4.c: The matching
wildcard is strict, but no declaration
can be found for element
'wss:binding'.
I think that the published examples are out of date and that, for Spring 3, the binding has to be defined in a different way.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:ws="http://jax-ws.java.net/spring/core"
xmlns:wss="http://jax-ws.java.net/spring/servlet"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<wss:binding url="/ws">
<wss:service>
<ws:service bean="#webService"/>
</wss:service>
</wss:binding>
<!-- this bean implements web service methods -->
<bean id="webService" class="com.test.TestService"/>
</beans>
How do I have to configure the binding, or where can I find a description.
For a start, you seem to be missing this in your schemaLocation:
http://jax-ws.java.net/spring/core http://jax-ws.java.net/spring/core.xsd
http://jax-ws.java.net/spring/servlet http://jax-ws.java.net/spring/servlet.xsd
(more here, but I guess you've seen it already)