Getting ReportUnit to show attachments - nunit

I've got an NUNIT test suite that properly generates an xml file with attachments, but can't find if there is a way to get ReportUnit to show those attachments in the rendered HTML.
Example - TestResult.xml contains:
<test-case id="0-1091" name="TestName" fullname="NUnitTestProject1.TestName" methodname="MethodName" classname="ClassName" runstate="Runnable" seed="92684126" result="Passed" start-time="2018-01-30 22:21:55Z" end-time="2018-01-30 22:21:55Z" duration="0.030017" asserts="5">
<properties />
<attachments>
<attachment>
<filePath>C:\Output\Result1.json</filePath>
<description><![CDATA[Request]]></description>
</attachment>
<attachment>
<filePath>C:\Output\Result2.png</filePath>
<description><![CDATA[Response]]></description>
</attachment>
</attachments>
</test-case>
It shows up when I run it in Visual Studio with the Name Outcome and Attachments
Visual Studio Result
But when I run ReportUnit on it the Attachments don't show up (in either passed tests or failed tests.)

Related

Publish Test Results task test name is not correct

In my trx file there are 3 test cases. The UnitTestResult name is below
Code:
<Results>
<UnitTestResult executionId="a009dca9-9a9c-45c6-966e-ce83b6a8f4d0" testId="c9427cd3-1949-4163-f8e9-3d620e7b7c04" testName="CampaignAdGroupCreationMSANAdCreatorSuite" computerName="71986a60c000008" duration="00:03:23.4530000" startTime="2022-11-17T00:20:46.3170000+00:00" endTime="2022-11-17T00:24:09.7700000+00:00" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Failed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="a009dca9-9a9c-45c6-966e-ce83b6a8f4d0" />
<UnitTestResult executionId="f61b0324-afe2-4b5a-b48d-e6fc2dbee4b0" testId="178fc87e-7321-761c-6004-c0824a26eaa4" testName="CampaignAdGroupCreationMSANAdCreatorSuite.should be able to apply effect to image added to an ad in create campaign workflow" computerName="71986a60c000008" duration="00:01:52.7160000" startTime="2022-11-17T00:21:15.6250000+00:00" endTime="2022-11-17T00:23:08.3410000+00:00" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Failed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="f61b0324-afe2-4b5a-b48d-e6fc2dbee4b0">
<UnitTestResult executionId="a5a4451b-675c-47ef-80f3-fba4a13c9b56" testId="5db0478b-94a4-a31f-ee72-883dbd15bb96" testName="CampaignAdGroupCreationMSANAdCreatorSuite.should be able to apply effect to image added to an ad in create adgroup workflow" computerName="71986a60c000008" duration="00:01:01.2260000" startTime="2022-11-17T00:23:08.3420000+00:00" endTime="2022-11-17T00:24:09.5680000+00:00" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Failed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="a5a4451b-675c-47ef-80f3-fba4a13c9b56">
</Results>
But in the 'Tests' tab, the test name are the same.
Click each one, the callstack and error message are correct.
Here is the test defination in the TRX file:
<TestDefinitions>
<UnitTest name="CampaignAdGroupCreationMSANAdCreatorSuite" storage="parentsuite" id="c9427cd3-1949-4163-f8e9-3d620e7b7c04">
<Execution id="a009dca9-9a9c-45c6-966e-ce83b6a8f4d0" />
<TestMethod codeBase="ParentSuite" adapterTypeName="executor://mochatestexecutor/" className="ParentSuite" name="CampaignAdGroupCreationMSANAdCreatorSuite" />
</UnitTest>
<UnitTest name="CampaignAdGroupCreationMSANAdCreatorSuite" storage="campaign-adgroup-creation-selenium" id="178fc87e-7321-761c-6004-c0824a26eaa4">
<Execution id="f61b0324-afe2-4b5a-b48d-e6fc2dbee4b0" />
<TestMethod codeBase="campaign-adgroup-creation-selenium" adapterTypeName="executor://mochatestexecutor/" className="CampaignAdGroupCreationMSANAdCreatorSuite" name="should be able to apply effect to image added to an ad in create campaign workflow" />
</UnitTest>
<UnitTest name="CampaignAdGroupCreationMSANAdCreatorSuite" storage="campaign-adgroup-creation-selenium" id="5db0478b-94a4-a31f-ee72-883dbd15bb96">
<Execution id="a5a4451b-675c-47ef-80f3-fba4a13c9b56" />
<TestMethod codeBase="campaign-adgroup-creation-selenium" adapterTypeName="executor://mochatestexecutor/" className="CampaignAdGroupCreationMSANAdCreatorSuite" name="should be able to apply effect to image added to an ad in create adgroup workflow" />
</UnitTest>
</TestDefinitions>
Could you please help to look?
Thanks.
The Tests tab was expected to show the correct test name.
I downgraded 'Publish test result' from V2 to V1.*, then I get the correct test list. It is just a workaround.

powershell azure function app throws an exception "Unable to find type [HttpResponseContext]" when debugging in VS 2022

I created a PowerShell azure Function App with the default/sample function in it.
On the function app 'overview' page I clicked the 'download app content' and downloaded the 'content and visual studio project' including the app settings.
I put the content into an empty folder on my dev computer and opened it with Visual Studio 2022.
Updated the .net.sdk.functions nuget package to 4.1.1 and set the target framework to 4.8
When I start the debugging the function loads and listens, but when I open the URL it throws an exception: "Unable to find type [HttpResponseContext]"
It looks like the 'using namespace System.Net' line in the powershell code doesn't work. (the code/debugging works on the same computer from VSCode, but I would prefer using VS2022)
Any help to make this work would be appreciated. Thank you in advance.
This is part of the .csproj file:
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.1" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
This is the code:
using namespace System.Net
# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
# Write to the Azure Functions log stream.
Write-Host "PowerShell HTTP trigger function processed a request."
# Interact with query parameters or the body of the request.
$name = $Request.Query.Name
if (-not $name) {
$name = $Request.Body.Name
}
$body = "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
if ($name) {
$body = "Hello, $name. This HTTP triggered function executed successfully."
}
# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]#{
StatusCode = [HttpStatusCode]::OK
Body = $body
})
Scenario 1:
Created PowerShell Core 7.2 Versioned Azure Function Http Trigger in the Azure Portal and downloaded it from the Overview blade with the following [Download App Content > Content & VS Project - Include app settings in the download].
Scenario 2:
When we create the same project from VS Code locally, it is not creating any .csproj file and if it is published without .csproj to Azure Portal Function App, Azure is sending the .csproj file in its Content and Visual Studio Project option with the net461 as target framework.
Error:
<Message>Exception while executing function: Functions.HttpTrigger1 -> PowerShell script error -> Unable to find type [HttpResponseContext].</Message>
....
<StatusCode>InternalServerError</StatusCode>
According to Azure Functions PowerShell Official Doc, .NET Framework is not supported in the PowerShell Runtime, but Azure is sending the framework version to the .csproj file.
We raised the triage ticket to the Microsoft on this issue and follow the updates from this GitHub ticket.

How do I have a meaningful error message from powershell script running in TeamCity build?

I have a TeamCity build and one of the steps is an MSBuild invokation of a .proj file:
Runner type: MSBuild
Build file path: TestProject.proj
Targets: Test
inside the .proj I have targets:
<Target Name="DeployTestService">
<Message Text="Deploying test service" />
<Exec Command="powershell -Command "& { myUsefulPsScript.ps }"" />
</Target>
<Target Name="Test">
// other stuff, then
<CallTarget Targets="DeployTestService" />
</Target>
and it works good most of the time. Yet if the powershell script fails (an unhandled exception is thrown and I can see its text in the full log) and exits with non-zero code I see the following in Teamcity build results:
Tests passed: (some number); exit code 1
and the build tree just says:
Build failure condition (1)
Process exited with code 1
[Time]Process exited with code 1
and until I get the full log I don't really know which step failed and how exactly. It's not about fixing the initial problem it's about locating the faulty step faster.
Is there a way to make Teamcity say something like "runner in step N failed with this error message [message which I see in the full log]"?
You need to use the Teamcity output format. For example, every time a new test starts, print:
##teamcity[testStarted name='foo|'s test']
This way Teamcity will know what was the last step or the last test before the app crashed and it will be able to format the output accordingly.

Set the name of an input control in a jrxml file. Is it possible?

I'd like to set the name of an input control in the jrxml file where it is defined; is that possible?
I know how to set the name of the input control via the Repository Explorer in Jaspersoft Studio, and I know how to set the name of an input control via the Jaspersoft Server.
However, I'd like to set the name of an input control in the jrxml file so that it will be set automatically upon being published to the server. Is there a property to use, similar to the following:
<parameter name="status_date_minimum" class="java.sql.Date">
<property name="some.property.key" vhalue="Minimum Status Date"/>
<defaultValueExpression><![CDATA[java.sql.Date.valueOf(java.time.LocalDate.now().minusYears(10).withMonth(1).withDayOfMonth(1))]]></defaultValueExpression>
</parameter>
As noted by #Siddharth in comments and suggested to me by a co-worker, there is a way to specify the label for the control outside of the user interface.
JasperReports Server associates each report with an XML file that it appears to create around the time it publishes your report to the server. The XML file contains, among other information, the labels for any input controls.
For an example of the XML file, first publish your report to a location on JasperReports Server. For the purpose of this example, the report file name is report.jrxml and the location is path/to/your; JasperReports Server appears to publish your report to path/to/your/report/Main jrxml (per JasperSoft Studio Repository Explorer) or path/to/your/report (per JasperReports Server Web UI).
Second, export your report from JasperReports Server (via the Web UI or via the command line); JasperReports Server will produce a zip file with the following content:
/index.xml
/resources/path/.folder.xml
/resources/path/to/.folder.xml
/resources/path/to/your/.folder.xml
/resources/path/to/your/report.xml
/resources/path/to/your/report_files/main_jrxml.data
main_jrxml.data contains the data from report.jrxml; report.xml contains the labels for any input controls. The content of report.xml may be similar to the following:
<?xml version="1.0" encoding="UTF-8"?>
<reportUnit exportedWithPermissions="true">
<folder>/resources/path/to/your</folder>
<name>report</name>
<version>2</version>
<label>report</label>
<description></description>
<creationDate>2018-03-21T18:12:41.759-04:00</creationDate>
<updateDate>2018-03-21T18:48:35.602-04:00</updateDate>
<mainReport>
<localResource
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
exportedWithPermissions="false" dataFile="main_jrxml.data" xsi:type="fileResource">
<folder>/resources/path/to/your/report_files</folder>
<name>main_jrxml</name>
<version>4</version>
<label>Main jrxml</label>
<creationDate>2018-03-21T18:12:41.759-04:00</creationDate>
<updateDate>2018-03-21T18:48:35.410-04:00</updateDate>
<fileType>jrxml</fileType>
</localResource>
</mainReport>
<inputControl>
<localResource
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
exportedWithPermissions="false" xsi:type="inputControl">
<folder>/resources/path/to/your/report_files</folder>
<name>status_date_minimum</name>
<version>1</version>
<label>status_date_minimum</label>
<creationDate>2018-03-21T18:48:35.602-04:00</creationDate>
<updateDate>2018-03-21T18:48:35.602-04:00</updateDate>
<type>2</type>
<mandatory>false</mandatory>
<readOnly>false</readOnly>
<visible>true</visible>
<dataType>
<localResource exportedWithPermissions="false" xsi:type="dataType">
<folder>/resources/path/to/your/report_files/status_date_minimum_files</folder>
<name>myDatatype</name>
<version>0</version>
<label>myDatatype</label>
<creationDate>2018-03-21T18:48:35.602-04:00</creationDate>
<updateDate>2018-03-21T18:48:35.602-04:00</updateDate>
<type>3</type>
<strictMin>false</strictMin>
<strictMax>false</strictMax>
</localResource>
</dataType>
</localResource>
</inputControl>
<inputControl>
<localResource
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
exportedWithPermissions="false" xsi:type="inputControl">
<folder>/resources/path/to/your/report_files</folder>
<name>status_date_maximum</name>
<version>1</version>
<label>status_date_maximum</label>
<creationDate>2018-03-21T18:48:35.602-04:00</creationDate>
<updateDate>2018-03-21T18:48:35.602-04:00</updateDate>
<type>2</type>
<mandatory>false</mandatory>
<readOnly>false</readOnly>
<visible>true</visible>
<dataType>
<localResource exportedWithPermissions="false" xsi:type="dataType">
<folder>/resources/path/to/your/report_files/status_date_maximum_files</folder>
<name>myDatatype</name>
<version>0</version>
<label>myDatatype</label>
<creationDate>2018-03-21T18:48:35.602-04:00</creationDate>
<updateDate>2018-03-21T18:48:35.602-04:00</updateDate>
<type>3</type>
<strictMin>false</strictMin>
<strictMax>false</strictMax>
</localResource>
</dataType>
</localResource>
</inputControl>
<alwaysPromptControls>true</alwaysPromptControls>
<controlsLayout>1</controlsLayout>
</reportUnit>
You may edit the content of the reportUnit/inputControl/localResource/label element to change the name of the label.
Once edited, you may import the data into the JasperReports Server. If you import through the command line, I recommend importing the directory, not the zip file - it appears that the command line import is picky about the zip format. Also, if you import through the command line, you must restart the JasperReports Server before you may run your changed report.

Why Msbuild task failed to deploy database, but Exec work fine

I'm trying to deploy database project ( dbproj format, not new SSDT sqlproj ) inside automated build server processing. I found the following:
When I'm calling deploy with Exec task in my Msbuild script - everything working fine:
<Exec Command="$(MSBuildPath)\MSBuild.exe $(SourceFilesPath)\$(DeployDatabaseProjectName)\$(DeployDatabaseProjectName).dbproj
/t:Deploy
/p:OutputPath=$(BaseOutput)\$(DeployDatabaseProjectName)\
/p:TargetDatabase=$(DeployDatabaseName)
/p:TargetConnectionString=$(DeployDatabaseConnectionString)" />
But when I try to repeat this with Msbuild task - it behaves differently:
<MSBuild Projects="$(SourceFilesPath)\$(DeployDatabaseProjectName)\$(DeployDatabaseProjectName).dbproj"
Targets="Deploy"
Properties="Configuration=$(BuildConfiguration);
TargetDatabase=$(DeployDatabaseName);
TargetConnectionString="$(DeployDatabaseConnectionString)";
OutputPath=$(BaseOutput)\$(DeployDatabaseProjectName)\;
" />
Msbuild task broke on semicolons in DeployDatabaseConnectionString:
<DeployDatabaseConnectionString>Data Source=$(DeployDatabaseServer);Integrated Security=True;Pooling=False</DeployDatabaseConnectionString>
It will report something like this:
The name "Integrated Security" contains an invalid character " ".
But if I replace semicolons with percent encoding value - %3B - it will broke inside SqlDeployTask:
error MSB4018: The "SqlDeployTask" task failed unexpectedly.
What is the proper way to pass TargetConnectionString to Deploy target of SqlProject ?
PS: I Could live with exec task fine, but make a call to msbuild.exe inside msbuild script just hurts my inner perfectionist man.
I found the proper way - new Msbuild allow to define AdditionalProperties metadata on item. So with this feature everything work fine and have no problems with escaping\encoding
<ItemGroup>
<DbProjectToBuild Include="$(SourceFilesPath)\$(DeployDatabaseProjectName)\$(DeployDatabaseProjectName).dbproj">
<AdditionalProperties>Configuration=$(BuildConfiguration)</AdditionalProperties>
<AdditionalProperties>OutputPath=$(BaseOutput)\$(DeployDatabaseProjectName)\</AdditionalProperties>
<AdditionalProperties>TargetDatabase=$(DeployDatabaseName)</AdditionalProperties>
<AdditionalProperties>TargetConnectionString="Data Source=$(DeployDatabaseServer);Integrated Security=True;Pooling=False"</AdditionalProperties>
</DbProjectToBuild>
</ItemGroup>
<MSBuild Projects="%(DbProjectToBuild.Identity)" Targets="Build;Deploy" />