我有一个数组,我正在像这样打印它:
echo "${data[*]}"
Run Code Online (Sandbox Code Playgroud)
输出:
/QE-CI-RUN-71/workspace/QE-AU/57/testng-results_1.xml
/QE-CI-RUN-71/workspace/QE-AU/57/testng-results_2.xml
Run Code Online (Sandbox Code Playgroud)
我想将上述输出存储为逗号分隔值。我怎样才能在 Bash 中实现这一目标?
数据数组是动态的,它可以有任意数量的值。
我在src/test/resources/feature /中有以下功能文件(单独的功能文件),我想并行运行它们.喜欢:一个功能文件必须在chrome中执行,另一个必须在firefox中执行,如@Tags名称所述.
Feature: Refund item
@chrome
Scenario: Jeff returns a faulty microwave
Given Jeff has bought a microwave for $100
And he has a receipt
When he returns the microwave
Then Jeff should be refunded $100
Feature: Refund Money
@firefox
Scenario: Jeff returns the money
Given Jeff has bought a microwave for $100
And he has a receipt
When he returns the microwave
Then Jeff should be refunded $100
Run Code Online (Sandbox Code Playgroud)
有人可以协助我实现这个目标.我使用的是cucumber-java 1.2.2版本,而AbstractTestNGCucumberTests则用作跑步者.另外,让我知道如何使用功能文件动态创建测试运行器并使它们并行运行.
我最近参加了一次面试,他们要求我使用时间复杂度来解决以下问题O(n)。(黑客排名)
问题:
给定一个整数数组,就会有l整数和r整数。需要找到哪些所有元素对的总和相等并且介于 和l之间r;
例子:
Run Code Online (Sandbox Code Playgroud)int[] array = {2,3,4,5}; int l=5, int r=7;输出:4
输入属性:
下面的组合将返回相等且在范围值之间的总和l,r如果该对小于l或大于r则应跳过。而且配对不能重复:
array[0] + array[1] = 5 -> counter++
array[0] + array[2] = 6 -> counter++
array[0] + array[3] = 7 -> counter++
array[1] + array[2] = 7 -> counter++
array[1] + array[3] = 8 -> greater than r, no counter increment
Run Code Online (Sandbox Code Playgroud)
我尝试了以下方法,效果很好,但时间复杂度为 O(n^2):
public …Run Code Online (Sandbox Code Playgroud) 我做了两行更改,但在 git 中,由于空格,它显示了更多的更改行。我们很难查看确切的代码更改。
下面是我用来推送代码的命令。
首先,我将从不同的 repo 中提取代码库并与我的本地合并。并将我的更改推送到我的分支,并提高 PR。
git add .
git commit -am "changes"
git pull upstream master
git push origin master
Run Code Online (Sandbox Code Playgroud)
但我也没有在我的 git 控制台中找到任何空格去除器选项。只有我能看到“UNIFIED”、“SPLIT”。
截屏
请找到以下示例屏幕截图以供参考。
有什么办法可以忽略所有提交的空白。
任何建议导致?
我有以下格式的 json 文件
{
"username":"achu",
"password":"test1234"
}
Run Code Online (Sandbox Code Playgroud)
我只想将时间戳添加到上述有效负载中并将其作为某些服务的请求发送。
据我所知,下面的命令将帮助我们获取 Linux 上的当前标记:
date +"%r"
Run Code Online (Sandbox Code Playgroud)
但不确定如何将其附加到上述有效负载中,如下所示:
预期的:
{
"username":"achu",
"password":"test1234",
"date":"1:20:30 AM PST"
}
Run Code Online (Sandbox Code Playgroud)
jq --版本
1.5V
这样可以得到吗?
我有 postman.collection.json 文件,我可以通过 newman 并使用以下命令运行这些集合文件。
newman run test.postman.collection.json -e environment.collection.json -d test.csv
Run Code Online (Sandbox Code Playgroud)
它运行成功并正在返回响应。
我只是想通过使用 Maven 系统获得相同的行为。我需要将它与 pom.xml 集成,以便该文件将运行上述集合。
这可能吗?如果可以这样运行,那么请分享一个示例来展示如何运行。
我在下面编写了正在运行并提供输出的代码。但是我不确定这是正确的。
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date date = new Date();
sdf.setTimeZone(TimeZone.getTimeZone("GMT-7"));
String value = sdf.format(date);
System.out.println(value);
Date date2 = sdf.parse(value);
long result = date2.getTime();
System.out.println(result);
return result;
Run Code Online (Sandbox Code Playgroud)
上面的代码我正在尝试的是,我只需要获取GMT时区的当前时间并将其转换为将在Oracle db中使用的纪元格式即可。
有人可以告诉我这种格式,并且上面的代码正确吗?
我正在尝试执行以下请求有效负载(JSON)并获取响应,如下所示:
卷曲命令:
curl --header "Content-Type: application/json" --header "hostname:kindle.qa.amazon.com" \
--request POST \
--data '{
"country":"BE",
"cardNumberPayment":"9423-8234-1882-3412",
"cardType" : "Visa",
"expirationMonth": "12",
"expirationYear": "2020"
}' \
http://amazon.qa.payment.com/v1/Services/restservices/credit
Run Code Online (Sandbox Code Playgroud)
回复:
{"cardType":"Visa","cardNumber":"9423823418823409","cvv":"***"}
{"cardType":"Visa","cardNumber":"9423823418823411","cvv":"***"}
{"cardType":"Visa","cardNumber":"9423823418823410","cvv":"***"}
Run Code Online (Sandbox Code Playgroud)
我只想获取curl 命令的cardNumber,而不是打印整个JSON(cardType 和cvv 除外)。
预期输出:
9423823418823409
9423823418823411
9423823418823410
Run Code Online (Sandbox Code Playgroud)
我只想单独获取卡号列表来打印作为输出。我怎样才能实现这个目标?
我对 Node.js 和 JS 世界非常陌生。我正在将记录器记录到现有的基于 Node.js 的测试应用程序中。我刚刚选择了“pino”并按如下方式使用它:
const pino = require('pino');
const logger = pino({
prettyPrint: true
});
logger.info("Flow---XXXX");
Run Code Online (Sandbox Code Playgroud)
当我运行时它返回以下响应npm run test | pino-pretty -c -t
输出:
[1589538447177]信息(L-MAA-13i28828820上的00020):流量---XXXX
我在这里有两个问题:
我在命令中设置了 -t 标志,我希望它将时间戳转换为用户理解的格式(如 yyyy-mm-dd HH:mm:ss),但它仍然打印纪元格式,如上所示。
我正在尝试将以下行添加到项目中的所有 JS 文件中。是否可以将其称为某个 JS 文件并将记录器对象导出到其他 js 文件中?这就像我可以创建可重用的 js 文件并导出函数,而不是在项目中的任何地方调用以下行吗?
Run Code Online (Sandbox Code Playgroud)const pino = require('pino'); const logger = pino({ prettyPrint: true });
我不确定这 2 个请求是否可以实现,但如果我能得到一些线索,那就太好了。
提前致谢。
更新:
我通过使用 module.export 选项解决了第一个问题,如下所示:
module.export.log = function(input)
{
logger.info(input);
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮助我在日志中显示用户可读的格式时间吗?现在它打印纪元..我尝试了下面的代码但仍然没有运气。
const logger = pino({
prettyPrint: true,
timestamp:`,"time":"${new Date(Date.now())}"`
});
Run Code Online (Sandbox Code Playgroud)
我可以看到 …
我有下面的 XSLT 文件,我只想通过 SHELL 脚本运行它。
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="test-method[@status = 'FAIL']"/>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
XML 示例:
<?xml version="1.0" encoding="UTF-8"?>
<test-result>
<test-method status="PASS" name="beforeTestSetup" is-config="true" duration-ms="705" started-at="2018-08-16T21:39:59Z" finished-at="2018-08-16T21:39:59Z">
<params>
<param index="0">
<value>
<![CDATA[org.testng.TestRunner@31c2affc]]>
</value>
</param>
</params>
</test-method>
<test-method status="FAIL" name="beforeTestSetup" is-config="true" duration-ms="805" started-at="2018-08-16T21:39:59Z" finished-at="2018-08-16T21:39:59Z">
<params>
<param index="0">
<value>
<![CDATA[org.testng.TestRunner@31c2affc]]>
</value>
</param>
</params>
</test-method>
<test-method status="PASS" name="TEST" is-config="true" duration-ms="905" started-at="2018-08-16T21:39:59Z" finished-at="2018-08-16T21:39:59Z">
<params>
<param index="0">
<value>
<![CDATA[org.testng.TestRunner@31c2affc]]>
</value>
</param>
</params>
</test-method>
</test-result>
Run Code Online (Sandbox Code Playgroud)
我只想通过 SHELL 脚本针对示例 XML …
基本上可以通过以下方式进行排序:
Collections.sort(列表);
但我的情况有点不同.我有一个包含以下对象的List.
示例代码1:
public class GetTraders {
private String getTraderLegalName;
private String businessName;
private Object status;
public GetTraders(String getTraderLegalName, String businessName, String status) {
this.getTraderLegalName=getTraderLegalName;
this.businessName=businessName;
this.status=status;
}
Run Code Online (Sandbox Code Playgroud)
我有一个课程,它将为以上列表提供如下价值:
public Class getResult {
List<GetTraders> traders=new ArrayList<GetTraders>();
public void valueGivenByuser(String legal,String business,Object status)throws Exception {
GetTraders trade=new GetTraders(legal,business,status);
traders.add(trade); //Adding value to arrayList
}
}
Run Code Online (Sandbox Code Playgroud)
这里的问题是,一旦我在交易者arraylist中添加了所有值,我需要排序并显示为输出.我尝试使用collections.sort()但它显示了编译器异常.