testing

How to make `it.only` environment-aware using mocha?

北城余情 提交于 2019-12-25 12:34:37
问题 Mocha supports it.only syntax to reduce the amount of tests to run. In our team, a developer might use it.only temporally within a code base. Now it happened that such an only test was approved and deployed by accident. This led the build server to happily run only one test and to declare that build a success. My question now becomes: Is there a way to tell mocha: It should only allow only on a developer's machine? Can it be make environment aware so that either all tests always run on a

Java: test methods of different parameter orderings

独自空忆成欢 提交于 2019-12-25 12:25:35
问题 I want to correctly validate a method regardless of the parameter ordering. Therefore, snippet 1 and 2 should both pass the test case in snippet 3. (snippet 1) public Integer compute_speed(Integer distance, Integer time) { return distance/time; } (snippet 2) public Integer compute_speed(Integer time, Integer distance) { return distance/time; } You can assume the two snippets as different code submissions by two students. And you can assume that the number of parameters can be as large as 10.

calabash-android run app-debug.apk throws exception

谁都会走 提交于 2019-12-25 09:28:37
问题 I am trying to run calabash-android to test my app, but I get the following error, the same app without any modification was working before I tried to do some modifications, but then I reverted all the modifications to the app : Exception occurred while dumping: java.lang.IllegalArgumentException: Unknown package: com.bitbar.testdroid at com.android.server.pm.Settings.isOrphaned(Settings.java:4134) at com.android.server.pm.PackageManagerService.isOrphaned(PackageManagerService.java:18091) at

Testing return value of SQLAlchemy parent-child relationship query

时间秒杀一切 提交于 2019-12-25 09:25:22
问题 Say I have two models set up like so: class ParentFoo(SqlBase): __tablename__ = "parents" id = Column(String, primary_key=True) children = relationship("ChildFoo", backref="parents") class ChildFoo(SqlBase): __tablename__ = "children" id = Column(String, primary_key=True) Now in a request handler, say I want to get all children entities from the database given a parent: class RequestHandler(): def get(self, parent_id): parent = database.query(parent_id) children = parent.children send

How to test Spring controller with multiple values for produces in RequestMapping Annotation?

混江龙づ霸主 提交于 2019-12-25 09:09:15
问题 I wanna test a certain controller method, which is serving images to client. Those images have different content types (jpg, png, gif). @RequestMapping(value="/getImage/{id}/{path}", produces = {"image/jpg", "image/gif", "image/png"}) @ResponseBody byte[] getImage(@PathVariable("id") String id, @PathVariable("path") String path) { File imageFile = handler.getImage(id, path); InputStream in; try { in = new FileInputStream(imageFile); return IOUtils.toByteArray(in); } catch (IOException e) { e

Python script to test for most recently modified file - inconsistent results

孤人 提交于 2019-12-25 08:59:38
问题 I found this post on stackoverflow which was exactly what I wanted to integrate into a larger script I am writing: Find the newest folder in a directory in Python I want to check for the newest file or folder so modified the script for testing as follows: #!/usr/bin/env python3.1 import os def allFilesIn(b='.'): result = [] for d in os.listdir(b): bd = os.path.join(b, d) result.append(bd) return result latest_subdir = max(allFilesIn('/tmp/testforlatest'), key=os.path.getmtime) print(latest

fgetwc EOF loop test fails, but 65535 OK

人盡茶涼 提交于 2019-12-25 08:56:57
问题 VS10 & MCBS: For this I have created a file called c:\eoftest containing the text "test" . The value of ch on the 5th pass in the following code is 65535 returned by fgetwc, but it does not equate to EOF, which we all know is defined in stdio.h as (-1): #include <stdio.h> #include <windows.h> int main() { int ch; FILE *stream = NULL; wchar_t buf[5]; memset (buf, '\0', sizeof(buf)); stream = _wfopen(L"C:\\eoftest.txt", L"r"); for (int i = 0; (i < (sizeof(buf) - 1) && ((ch = fgetwc(stream)) !=

Error: Could not get the Java version. Is Java installed?

。_饼干妹妹 提交于 2019-12-25 08:45:40
问题 I run Appium server: ➜ ~ appium info: Welcome to Appium v1.3.5 (REV a124a15677e26b33db16e81c4b3b34d9c6b8cac9) info: Appium REST http interface listener started on 0.0.0.0:4723 info: Console LogLevel: debug info: --> POST /wd/hub/session {"desiredCapabilities":{"appPackage":"com.grindrapp.android","appActivity":".activity.SplashActivity","platformVersion":"4.4.2","browserName":"","platformName":"Android","deviceName":"10.0.0.9:5555"}} info: Client User-Agent string: Apache-HttpClient/4.3.4

Counter Not Testing As Expected? [VHDL]

淺唱寂寞╮ 提交于 2019-12-25 07:51:29
问题 I'm trying to make a 32 bit counter in VHDL. Below is my code: LIBRARY ieee; USE ieee.std_logic_1164.ALL; USE ieee.numeric_std.ALL; ENTITY counter32 IS PORT (en, clk, clr: IN STD_LOGIC; count: OUT STD_LOGIC_VECTOR(4 DOWNTO 0)); END counter32; ARCHITECTURE rtl OF counter32 IS SIGNAL count_result: STD_LOGIC_VECTOR(4 DOWNTO 0); BEGIN counter32: PROCESS(clk, clr) BEGIN count <= "00000"; --Initialize counter to all zeroes IF (clr = '0') THEN count_result <= "00000"; ELSIF (clk = '1' and clk'EVENT)

RSpec: Authenticating before test with devise_auth_token

社会主义新天地 提交于 2019-12-25 07:49:10
问题 I am using devise_auth_token to authenticate users for an API. I would like to authenticate users before each test is run, but keep getting a 401 error. When I use postman to the endpoint with the correct headers, it works, but fails to work during tests. before(:each) do @user = FactoryGirl.create(:user) end def get_auth headers = @user.create_new_auth_token auth = Hash.new auth["client"] = headers["client"] auth["access-token"] = headers["access-token"] auth["uid"] = headers["uid"] auth[