小编use*_*183的帖子

使用while循环时Bash退出状态

我有一个bash脚本,它通过一个ip列表并逐个ping它们.如果每个ping的退出状态为0,则回显节点已启动,否则节点已关闭.我能够使其完美运行,但是当bash脚本结束时,退出状态始终为0.

我想要实现的是例如5个ip中的第3个如果第3个失败,继续通过列表并检查其余部分但是一旦脚本结束抛出除0以外的退出状态并输出哪个ip失败.

cat list.txt |  while read -r output
do
    ping -o -c 3 -t 3000 "$output" > /dev/null
    if [ $? -eq 0 ]; then
    echo "node $output is up"
    else
    echo "node $output is down"
    fi
done
Run Code Online (Sandbox Code Playgroud)

提前致谢!

linux bash loops ping

5
推荐指数
1
解决办法
870
查看次数

Maven 没有运行测试

我在 Eclipse 中创建了一个新的 maven 项目,它通过使用 HtmlUnitDriver 和 FirefoxDriver 来运行简单的测试来拉出一个网页并检查页面上的标题。当我运行 maven 命令 mvn test 这就是我得到的全部:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ my-app ---
[WARNING] Using platform encoding (MacRoman actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/Andrew/Development/code/my-app/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ my-app ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) …
Run Code Online (Sandbox Code Playgroud)

java eclipse apache selenium maven

2
推荐指数
1
解决办法
1万
查看次数

如何在Jenkins上运行Selenium/WebDriver测试?

我是Selenium和Automation的新手.使用Selenium IDE和我对Java的一般知识,我能够在Eclipse中生成一系列在JUnit上运行的测试用例.现在我的测试目前在我日食时运行并按下[run].我想将这些测试用例导入Jenkins/Hudson.有两种方法我更喜欢做CI.

  1. 安排一个时间(每周一次)来完成测试并发送结果的电子邮件.

  2. 将我的测试用例上传到GitHub上的存储库,当存储库发生更改时,运行测试和/或按计划(每周一次).

老实说,我试图查找教程(视频/文件),但他们似乎都很不清楚.举个例子,我不知道build.xml或POM是什么.

使用Jenkins插件或使用ANT或Maven更好吗?如果是这样,我需要在代码中添加/更改以允许这种情况发生的事情,并在Jenkins中进行配置.

我的示例代码如下:

package Profile;

import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.Select;
import com.opera.core.systems.scope.protos.ExecProtos.ActionList.Action;

public class P_ProfileChangeTestCase {
  private WebDriver driver;
  private String baseUrl;
  private StringBuffer verificationErrors = new StringBuffer();

//Before the test begins, creates a new webdriver and sets the base url
  @Before
  public void setUp() throws Exception {
    driver = new FirefoxDriver();
    baseUrl = "http://www.test.com/";
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

  }

  @Test
  public void testOpen() …
Run Code Online (Sandbox Code Playgroud)

ant junit selenium jenkins

1
推荐指数
1
解决办法
1377
查看次数

如何在Javascript中写入CSV文件

我有一个脚本(使用PhantomJS)来测试加载网页所需的时间.我想弄清楚的是如何写入将页面加载到.csv文件所花费的时间的结果.然后,如果我再次重新运行测试,它将另一个结果添加到.csv文件中.

码:

var page = require('webpage').create(),
    system = require('system'),
    t, address;
var pageLoadArray = [];
var csvContents = "";
fs = require('fs');

if (system.args.length === 1) {
    console.log('Usage: loadspeed.js <some URL>');
    phantom.exit(1);
} else {
    t = Date.now();
    address = system.args[1];
    page.open(address, function (status) {
        if (status !== 'success') {
            console.log('FAIL to load the address');
        } 
        else {
            t = Date.now() - t;
            console.log('Page title is ' + page.evaluate(function () {
                return document.title;
            }));

            if(t>7000){
                console.log('Loading time was too long... …
Run Code Online (Sandbox Code Playgroud)

javascript csv jenkins phantomjs

1
推荐指数
1
解决办法
8285
查看次数

标签 统计

jenkins ×2

selenium ×2

ant ×1

apache ×1

bash ×1

csv ×1

eclipse ×1

java ×1

javascript ×1

junit ×1

linux ×1

loops ×1

maven ×1

phantomjs ×1

ping ×1