How can I add timestamps to the HTML report for the test run start/end and for scenario start/end in Cucumber-JVM?
Is there a Cucumber option I can add to RunWith JUnit runner?
It's simple!!!!!!
Don't mention any folder path in plugin com.cucumber.listener.ExtentCucumberFormatter.
Example :
plugin= { "pretty", "html:FeaturesReport", "html:target/site/cucumber-pretty", "json:target/cucumber.json",
"com.cucumber.listener.ExtentCucumberFormatter:",
},
Run project and refresh it.
check report will generate in default folder output/Run_with system time/report.html
If you want to generate a report in a specified path with a timestamp
just follow the below steps.
goto maven dependencies.
search cucumber-extentsreport.jar
extend jar and select com.cucumber.listener package
copy entire code in ExtentProperties class
right on package and create new enum with name of ExtentProperties
then paste ExtentProperties class code in the created enum.
search below method
ExtentProperties() {
this.reportPath = "output" + File.separator + "Run_" + System.currentTimeMillis() +File.separator+ "report.html";
this.projectName = "default";
}
8.And Replace With below code
String timeStamp = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Date());
String userDir =System.getProperty("user.dir");
ExtentProperties()
{
this.reportPath = "Extent_Reports" + File.separator + "" +
timeStamp.replace(":","").replace(".","_") + File.separator + "Execution
report.html";
this.projectName = "default";
}
Run the project then refresh the project.
10.check report will generate in specified path with the name.
Extent_Reports/_2020_06_16_19_14_07/Execution report.html
Please comment if you have any questions
Work with latest cucumber version, you can get start timestamp of each scenario in json report as below:
"elements": [
{
"start_timestamp": "2019-11-18T11:06:15.606Z",
....
}
Related
I have a task which restores our NuGet package for our dotnet core application:
Task("Restore-Packages")
.Does(() =>
{
DotNetCoreRestore(sln, new DotNetCoreRestoreSettings {
Sources = new[] {"https://my-team.pkgs.visualstudio.com/_packaging/my-feed/nuget/v3/index.json"},
Verbosity = DotNetCoreVerbosity.Detailed
});
});
However when run on VSTS it errors with the following:
2018-06-14T15:10:53.3857512Z C:\Program Files\dotnet\sdk\2.1.300\NuGet.targets(114,5): error : Unable to load the service index for source https://my-team.pkgs.visualstudio.com/_packaging/my-feed/nuget/v3/index.json. [D:\a\1\s\BitCoinMiner.sln]
2018-06-14T15:10:53.3857956Z C:\Program Files\dotnet\sdk\2.1.300\NuGet.targets(114,5): error : Response status code does not indicate success: 401 (Unauthorized). [D:\a\1\s\BitCoinMiner.sln]
How do I authorize access for the build agent to our private VSTS?
I literally just had this same problem, apparently the build agents in VSTS can't get to your private VSTS feed without an access token so you are going to have to create a Personal Access Token in VSTS and provide that to the built in Cake method to add an authenticated VSTS Nuget feed as one of the sources. Here, I have wrapped it in my own convenience Cake method that checks to see if the package feed is already present, if not, then it adds it:
void SetUpNuget()
{
var feed = new
{
Name = "<feedname>",
Source = "https://<your-vsts-account>.pkgs.visualstudio.com/_packaging/<yournugetfeed>/nuget/v3/index.json"
};
if (!NuGetHasSource(source:feed.Source))
{
var nugetSourceSettings = new NuGetSourcesSettings
{
UserName = "<any-odd-string>",
Password = EnvironmentVariable("NUGET_PAT"),
Verbosity = NuGetVerbosity.Detailed
};
NuGetAddSource(
name:feed.Name,
source:feed.Source,
settings:nugetSourceSettings);
}
}
and then I call it from the "Restore" task:
Task("Restore")
.Does(() => {
SetUpNuget();
DotNetCoreRestore("./<solution-name>.sln");
});
Personally, I prefer to keep PATs away from the source control so here I am reading from env vars. In VSTS you can create an environment variable under the Variables tab of your CI build configuration.
Hope this helps! Here is a link to Cake's documentation.
As pointed out by both #KevinSmith and #NickTurner, a better approach to accessing the VSTS feed is by using the pre-defined system variable System.AccessToken as opposed to using limited validity, manually created and cumbersome PATs. This variable is available on the build agents for the current build to use. More info here.
One way of using this token in the Cake script is as follows:
First, expose the system variable as an environment variable for the Cake task in azure-pipelines.yml
steps:
- task: cake-build.cake.cake-build-task.Cake#0
displayName: 'Cake '
inputs:
target: Pack
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
Then in Cake you can access it like you would any environment variable, so in my case:
if (!NuGetHasSource(source:feed.Source))
{
Information($"Nuget feed {feed.Source} not found, adding...");
var nugetSourceSettings = new NuGetSourcesSettings
{
UserName = "whoosywhatsit",
Password = EnvironmentVariable("SYSTEM_ACCESSTOKEN"),
Verbosity = NuGetVerbosity.Detailed
};
NuGetAddSource(
name:feed.Name,
source:feed.Source,
settings:nugetSourceSettings);
}
This seems to work! If there are better approaches of accessing this variable in Cake please let me know. Please also note in my case, I am only using this to restore packages from my VSTS feed, not for pushing to it. That I do via a DotNetCoreCLI#2 task in the YML like so:
- task: DotNetCoreCLI#2
displayName: 'dotnet nuget push'
inputs:
command: push
packagesToPush: 'artifacts/package.nupkg'
publishVstsFeed: '<id of my VSTS feed>'
And Azure pipeline handles the rest.
For a couple of years, I have been releasing updates to a modest app on a yearly basis -- just before the summer swim league starts up.
In the past, I have specified the various icons (volume, app, etc.) by placing them in the package/macosx/ folder. The filenames, MyApp-volume.icns etc., matched the <fx:application name="MyApp" .../> and everything worked just fine.
But starting with this year's build and deployment, the app's name will contain the year -- i.e., MyApp 2016. However, I don't want to be changing the icon filenames each year; I would like to keep them as they are (MyApp-volume.icns, MyApp.icns).
Is there a way to tell the Java packager to use a specific icon filename, one that is different from that of the app name or title? (I have looked at Oracle docs, but I don't see anything.)
-Bicon=<path to icon relative to project resourses>
is this what you looking for?
or you could just add it to your main app Stage.
hope it is usefull
As I wrote in my first comment to my question, javapackager doesn't have an option to do this.
Here's the solution that I worked out:
Create a new folder at the same level as the folder package (this doesn't refer to Java package but to Custom Resources). Name the new folder package-base.
Move the macosx and windows folders from package to package-base. (I don't produce an executable for Linux because none of my users use Linux.) Now, the package folder is empty.
In my build script, I added a step which, for every build that produces a "self-contained application package" (Oracle's terminology), cleans the package folder, and then copies the contents of package-base to package.
The files are renamed as they are copied to include the desired wording -- in my case, that means the year is appended to the filename. For example, MyApp-volume.icns when copied is renamed MyApp-2018-volume.icns.
Here are the relevant Gradle snippets:
import org.gradle.internal.os.OperatingSystem
...
def getYear() {
new Date().format('yyyy')
}
...
ext {
...
year = getYear()
appNameBase = "MyApp"
appName = appNameBase + " " + year
...
}
...
task macCleanPackage {
doLast {
if (OperatingSystem.current().isMacOsX()) {
delete fileTree(dir: "./package/macosx", include: "*.*")
}
}
}
task macCopyAndRenamePackageResources {
dependsOn macCleanPackage
doLast {
if (OperatingSystem.current().isMacOsX()) {
def toDir = "./package/macosx"
copy {
from './package-base/macosx'
into "${toDir}"
include "*${appNameBase}*.*"
rename { String fileName -> fileName.replace("$appNameBase", "${appName}") }
}
ant.replaceregexp(file: "${toDir}/${appName}-dmg-setup.scpt", match:"${appNameBase}", replace:"${appName}", flags:'g')
}
}
}
task windowsCleanPackage {
doLast {
if (OperatingSystem.current().isWindows()) {
delete fileTree(dir: "package/windows", includes: ["*.bmp", "*.ico", "*.iss"])
}
}
}
task windowsCopyAndRenamePackageResources {
dependsOn windowsCleanPackage
doLast {
if (OperatingSystem.current().isWindows()) {
def toDir = "./package/windows"
copy {
from './package-base/windows'
into "${toDir}"
include "*${appNameBase}*.*"
rename { String fileName -> fileName.replace("$appNameBase", "${appName}") }
}
// Replace app name in iss setup script to include year.
def issFilename = "./package/windows/${appName}.iss"
ant.replaceregexp(file: "${issFilename}", match: "${appNameBase}", replace: "${appName}", flags: "g")
ant.replaceregexp(file: "${issFilename}", match: "AppCopyright=Copyright (C)", replace: "AppCopyright=Copyright (C) ${year}", byline: "on")
ant.replaceregexp(file: "${issFilename}", match: "AppVersion=", replace: "AppVersion=${year} build ${buildNumber}", byline: "on")
ant.replaceregexp(file: "${issFilename}", match: "OutputBaseFilename=.*", replace: "OutputBaseFilename=${appName}-(build ${buildNumber})", byline: "on")
}
}
}
I don't just change filenames.
For the OS X release, ant.replaceregexp is used to modify the app's name in the custom AppleScript file.
For the Windows release, ant.replaceregexp is used extensively to replace version numbers, copyright, as well as the application's name (including the year) in the InnoSetup configuration file.
It may seem like a lot of extra work, but once the script is written, it just works.
How can I list all files inside a folder with Meteor.I have FS collection and cfs:filesystem installed on my app. I didn't find it in the doc.
Another way of doing this is by adding the shelljs npm module.
To add npm modules see: https://github.com/meteorhacks/npm
Then you just need to do something like:
var shell = Meteor.npmRequire('shelljs');
var list = shell.ls('/yourfolder');
Shelljs docs:
https://github.com/arturadib/shelljs
The short answer is that FS.Collection creates a Mongo collection that you can treat like any other, i.e., you can list entries using find().
The long answer...
Using cfs:filesystem, you can create a mongo database that mirrors a given folder on the server, like so:
// in lib/files.js
files = new FS.Collection("my_files", {
stores: [new FS.Store.FileSystem("my_files", {"~/test"})] // creates a ~/test folder at the home directory of your server and will put files there on insert
});
You can then access this collection on the client to upload files to the server to the ~test/ directory:
files.insert(new File(['Test file contents'], 'my_test_file'));
And then you can list the files on the server like so:
files.find(); // returns [ { createdByTransform: true,
_id: 't6NoXZZdx6hmJDEQh',
original:
{ name: 'my_test_file',
updatedAt: (Date)
size: (N),
type: '' },
uploadedAt: (Date),
copies: { my_files: [Object] },
collectionName: 'my_files'
}
The copies object appears to contain the actual names of the files created, e.g.,
files.findOne().copies
{
"my_files" : {
"name" : "testy1",
"type" : "",
"size" : 6,
"key" : "my_files-t6NoXZZdx6hmJDEQh-my_test_file", // This is the name of the file on the server at ~/test/
"updatedAt" : ISODate("2015-03-29T16:53:33Z"),
"createdAt" : ISODate("2015-03-29T16:53:33Z")
}
}
The problem with this approach is that it only tracks the changes made through the Collection; if you add something manually to the ~/test directory, it won't get mirrored into the Collection. For instance, if on the server I run something like...
mkfile 1k ~/test/my_files-aaaaaaaaaa-manually-created
Then I look for it in the collection, it won't be there:
files.findOne({"original.name": {$regex: ".*manually.*"}}) // returns undefined
If you just want a straightforward list of files on the server, you might consider just running an ls. From https://gentlenode.com/journal/meteor-14-execute-a-unix-command/33 you can execute any arbitrary UNIX command using Node's child_process.exec(). You can access the app root directory with process.env.PWD (from this question). So in the end if you wanted to list all the files in your public directory, for instance, you might do something like this:
exec = Npm.require('child_process').exec;
console.log("This is the root dir:");
console.log(process.env.PWD); // running from localhost returns: /Users/me/meteor_apps/test
child = exec('ls -la ' + process.env.PWD + '/public', function(error, stdout, stderr) {
// Fill in this callback with whatever you actually want to do with the information
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if(error !== null) {
console.log('exec error: ' + error);
}
});
This will have to run on the server, so if you want the information on the client, you'll have to put it in a method. This is also pretty insecure, depending on how you structure it, so you'd want to think about how to stop people from listing all the files and folders on your server, or worse -- running arbitrary execs.
Which method you choose probably depends on what you're really trying to accomplish.
I am using Freshdocs for Android
I can login to the Alfresco server using this API call:
GET /alfresco/service/api/login?u={username}&pw={password?}
But how do I create a new folder in Alfresco?
There are two main options, but it'll depend on what else you want to do, and what version of Alfresco you're running.
Assuming you want to keep things very simple, and you just want to create one folder, and you're using Alfresco 4.1 or later, then you can use the org.alfresco.repository.node.folder.post webscript. For this, simply post JSON like either
{ "name": "NewNodeName" }
or
{
"name": "NewNodeName",
"title": "New Node Title",
"description": "A shiny new node",
"type": "cm:folder"
}
To the API, which takes a URL like /api/site/folder/{site}/{container}/{path}
Alternately, if you want to do a number of different file and folder operations (eg navigate the folder structure, create a folder, upload a file to it etc), then you should instead use CMIS. Apache Chemistry is a great library to use for CMIS, and it even has an Android client! The docs for the android client are still being written thought (the Android port was only just added), so you might need to ask on the mailing list if you don't have time to wait for the docs.
To create a folder through api you can use the following queries:
a) To create defined type folder using full path to parent folder
url: "/../alfresco/service/api/site/folder/" + siteName + "/documentLibrary/" + parentFolderPath
method: "POST"
json: {
name: name
type: folderType
}
siteName - website name created in Alfresco;
parentFolderPath - path to parent folder;
name -folder name;
type - folder type.
Example:
url: "/../alfresco/service/api/site/folder/example/documentLibrary/books"
method: "POST"
json: {
name: "Pushkin"
type: "cm:folder"
}
After making the request "Pushkin" folder is created. This folder is situated in “books” folder of documents library on the "example" website.
b) To create folder by nodeRef
nodeRef is an object id in Alfresco. Each object has its own nodeRef. This request creates new object inside given object of folder type.
xml = '<?xml version="1.0" encoding="utf-8"?>' + '<entry xmlns="http://www.w3.org/2005/Atom"
xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/"
xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/">' +
'<title>' + folderName + '</title>' +
'<summary>' + folderName + '</summary>' +
'<cmisra:object>' +
'<cmis:properties>' +
'<cmis:propertyId
propertyDefinitionId="cmis:objectTypeId">' +
'<cmis:value>' + folderType + '</cmis:value>' +
'</cmis:propertyId>' +
'</cmis:properties>' +
'</cmisra:object>' +
'</entry>';
url: "/../alfresco/service/api/node/workspace/SpacesStore/" +
nodeRef + "/children"
method: "POST"
headers: {
"Content-Type": "application/atom+xml;type=entry"
},
xml: xml
folderName - folder name;
folderType - folder type;
nodeRef - folder id in Alfresco.
Example:
nodeRef = b544cd67-e839-4c60-a616-9605fa2affb7;
xml = '<?xml version="1.0" encoding="utf-8"?>' +
'<entry xmlns="http://www.w3.org/2005/Atom"
xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/"
xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/">' +
'<title>Example of creating a folder</title>' +
'<summary>Example of creating a folder</summary>' +
'<cmisra:object>' +
'<cmis:properties>' +
'<cmis:propertyId propertyDefinitionId="cmis:objectTypeId">' +
'<cmis:value>cm:folder</cmis:value>' +
'</cmis:propertyId>' +
'</cmis:properties>' +
'</cmisra:object>' +
'</entry>';
url: "/../alfresco/service/api/node/workspace/SpacesStore/" + nodeRef + "/children"
method: "POST"
headers: {
"Content-Type": "application/atom+xml;type=entry"
},
xml: xml
Other services and their description you can find here:
http://jazzteam.org/en/technical-articles/list-of-alfresco-services/
You should use
POST /alfresco/service/api/path/{store_type}/{store_id}/{id}/children
Read the docs for detailed information:
http://wiki.alfresco.com/wiki/Repository_RESTful_API_Reference#Create_folder_or_document_.28createDocument.2C_createFolder.29
I am trying to add a web module in an Ear file. I put it in my customized deployment descriptor using webModule(":wars/myweb","/mywebapp"). It is not including the war file in the ear file. It is just adding a entry in the generated application.xml with these details.
Can you please help in including a web module in ear, using customized deployment descriptor?
My ear task looks like this in build.gradle
ear {
libDirName ''
deploymentDescriptor {
// custom entries for application.xml:
// fileName = "application.xml" // same as the default value
version = "1.4" // same as the default value
applicationName = "myapp"
initializeInOrder = true
displayName = "myear" // defaults to project.name
description = "EAR for the basic package" // defaults to project.description
webModule(':wars/myweb','/mywebapp')
}
}
My settings.xml in the same dir as build.gradle looks like this
include "wars/myweb"
Appreciate your help.
I use this way to tie war dependencies to the webModules. The warMap provides a connection between the artifact id and the context path:
Map warMap = [
'my-war': 'contextpath',
'my2-war': 'contextpath2'
}
dependencies {
warMap.each {
deploy project(":$it.key")
}
}
ear {
deploymentDescriptor {
warMap.each {
webModule(it.key + '-' + project.version + ".war", it.value)
}
}
}