testing

R - testthat using data file outside the testing directory

百般思念 提交于 2019-12-23 07:27:25
问题 I am using testthat to test a package with a file tree similar to the following: . ├── data │ └── testhaplom.out ├── inst │ └── test │ ├── test1.r │ ├── tmp_S7byVksGRI6Q │ │ └── testm.desc │ └── tmp_vBcIkMN1arbn │ ├──testm.bin │ └── testm.desc ├── R │ ├── haplom.r │ └── winIdx.r └── tmp_eUG3Qb0PKuiN └── testhaplom.hap2.desc In the test1.r file, I need to use the data/testhaplom.out file as input data for a certain function, but if I do test_file(test1.r) , it changes into the inst/test

Hide output during PHPUnit test execution

僤鯓⒐⒋嵵緔 提交于 2019-12-23 07:13:09
问题 I have some var_dumps in my php code (i understand what there must be none in the end, but still), and while tests are running they outputs non necessary information to console, is there a method to ignore some code execution? I've tried /** * @codeCoverageIgnore */ and // @codeCoverageIgnoreStart print '*'; // @codeCoverageIgnoreEnd But this just ignores coverage, and still executes the code. 回答1: You can set the setOutputCallback to a do nothing function. The effect is to suppress any

Testing in Python - how to use assertRaises in testing using unittest? [duplicate]

让人想犯罪 __ 提交于 2019-12-23 07:03:18
问题 This question already has answers here : How do you test that a Python function throws an exception? (13 answers) Closed last year . I am trying to do a simple test in Python using unittest, to see if a class throws an exception if it gets an unsuitable input for the constructor. The class looks like this: class SummaryFormula: def __init__( self, summaryFormula): self.atoms = {} for atom in re.finditer( "([A-Z][a-z]{0,2})(\d*)", summaryFormula): symbol = atom.group(1) count = atom.group(2)

How can I stub/mock a function in the javascript global namespace

爷,独闯天下 提交于 2019-12-23 06:57:53
问题 I'm trying to stub/mock/override a function call during testing which writes a log to a DB. function logit(msg) { writeMessageToDb(msg); } function tryingToTestThisFunction(){ var error = processSomething(); if (error) { logit(error); } } I'd like logit() to simply print to the console during testing...and doing a " isTesting() " if/else block inside the logit() function is not an option. Is this possible without including some additional mocking framework. I'm currently using JsTestDriver

Can't find element to click on using Capybara + Rails3

☆樱花仙子☆ 提交于 2019-12-23 06:48:24
问题 Background : I'm using Capybara with Rspec to test a Rails 3 app. Driver used : Selenium Problem : I can't find the "Sign in" button in order to click on from within my test. HTML code: <form accept-charset="UTF-8" action="/" class="filter_form" id="login" method="post"> <fieldset> <div class="modal-body"> <div class="clearfix login-fields"> <label for="user_email">Email</label> <div class="input login-inputs"> <input class="input-text" id="user_email" name="user[email]" placeholder="email"

Functional test based on nlog output

天涯浪子 提交于 2019-12-23 05:41:42
问题 I got some tests which relies on the output from Nlog. I've managed to redirect the output to a variable so I can dive into the string to figured out if all went ok. There must be a better way of doing this but I couldn't manage to find anything. Here's the test and the class being tested: [TestFixture] public class ProcessMessagesFromQueues { private static string StuffLogged; [SetUp] public void Init() { StuffLogged = string.Empty; RedirectNLog(); } private static void RedirectNLog() {

Zend_Test: Assert Controller Failed

徘徊边缘 提交于 2019-12-23 05:39:07
问题 I use Zend_Test for unit testing in Zend Framework. I have configured the bootstrap and testing environment properly then I got this error output from test unit Failed asserting last controller used <"error"> was "index" This error happens when I call my DbTable class inside action method such as public function indexAction() { $roleDb = new Model_DbTable_Role; $role = $roleDb->getAll(); $this->_forward('login'); } If I remove two lines role, unit testing is success. It is my unit testing

How to best simulate IO bound work?

一个人想着一个人 提交于 2019-12-23 05:33:16
问题 It's easy to simulate a heavy CPU load. public void ExerciseCPU() { for (int i = 0; i < 999; i++) for (int j= 0; j < 999; j++) for (int k = 0; k < 999; k++) int x = i * j * k; } What's a comparable short code block for simulating heavy or slow IO? In other words, what's a technique for simulating a slow process that's light on the CPU? 回答1: Assuming you want to test your app for long delays during IO in your mocked/intercepted IO layer: Thread.Sleep will simulate non-CPU load perfectly fine

Expecting a stackmap frame - Java 8

限于喜欢 提交于 2019-12-23 05:28:04
问题 I am getting this error "Expecting a stackmap frame at this location". I am using Java 8. I know that for Java 7 there is a workaround to use -XX:-UseSplitVerifier to use the less strict verification method. However that option was removed in Java 8. I was wondering if there is any other solution for this. Switching to an earlier Java is not an option. 回答1: The option -XX:-UseSplitVerifier was intended to give bytecode library and tool developers time to catch up and fix problems with

How to click a button in row in a table using protractor js

你离开我真会死。 提交于 2019-12-23 05:23:29
问题 I am writing protractor test cases. I want to click on edit button. When I am checking by id it is not found. Code: <table class="table table-bordered table-hover"> <thead> <tr> <th>Code</th> <th>Start Date</th> <th></th> </tr> </thead> <tbody> <tr ng-repeat="batch in batches.list"> <td><a ui-sref="root.courses.detail.batches.assessments({ batch_id: batch.id,assessment_status: 'published'})">BID00{{batch.id}}</a></td> <td>{{batch.start_date}}</td> <td> <button id="edit" type="button" class=