tdd

Testing Chef roles and environments

我的梦境 提交于 2019-11-30 13:21:38
I'm new to Chef and have been using Test Kitchen to test the validity of my cookbooks, which works great. Now I'm trying to ensure that environment-specific attributes are correct on production nodes prior to running Chef initially. These would be defined in a role. For example, I may have recipes that converge using a Vagrant box with dev settings, which validates the cookbook. I want to be able to test that a production node's role. I think I want these tests as the source of truth describing my environment. Looking at Test Kitchen's documentation, this seems beyond its scope. Is my

Java mock database connection [closed]

不羁岁月 提交于 2019-11-30 11:44:47
I want to test class with make db connection. Class that I want to test accept as param in constructor Connection class. I want to pass mock object to the constructor. Can you tell me good framework with example how to mock db connection? Tomasz Nurkiewicz You can use MockRunner , which has support for JDBC . General mocking frameworks like Mockito will also work, but JDBC is a set of interfaces returning each other so hand-mocking will be hard. See for yourself: How to stub/mock JDBC ResultSet to work both with Java 5 and 6? However mocking JDBC is so brittle and verbose (no matter which

How can I load this file into an NUnit Test?

六眼飞鱼酱① 提交于 2019-11-30 11:38:56
问题 I have the following IntegrationTest project structure ... If i wish to use that test data 126.txt in an NUnit Test , how do I load that plain txt file data? NOTE: The file is -linked- and I'm using c# (as noted by the image). cheers :) 回答1: You could specify in the properties of the file to be copied to the output folder and inside the unit test: string text = File.ReadAllText(TestContext.CurrentContext.TestDirectory + "\\TestData\\126.txt"); As an alternative you could embed this file as a

eslint should be listed in the project's dependencies, not devDependencies

六月ゝ 毕业季﹏ 提交于 2019-11-30 11:37:28
问题 Either I don't understand dependencies vs. devDependencies in node 100% yet or eslint is just wrong here (not capable of analyzing this correctly): 3:1 error 'chai' should be listed in the project's dependencies, not devDependencies import/no-extraneous-dependencies 4:1 error 'chai-enzyme' should be listed in the project's dependencies, not devDependencies import/no-extraneous-dependencies 5:1 error 'enzyme' should be listed in the project's dependencies, not devDependencies import/no

Handling unit tests with a condition on the current time

女生的网名这么多〃 提交于 2019-11-30 11:31:04
I'm taking a stab at setting up unit tests for some utility classes in a project I'm working on, and one of the classes (contains licensing info) has a method that does some determination based on the current time. i.e. the license contains an expiry date, and the license string validates that date, but the actual logic to see if the license is expired is based on the current time. public boolean isValid() { return isLicenseStringValid() && !isExpired(); } public boolean isExpired() { Date expiry = getExpiryDate(); if( expiry == null ) { return false; } Date now = new Date(); return now.after(

How can I get my jasmine tests fixtures to load before the javascript considers the document to be “ready”?

两盒软妹~` 提交于 2019-11-30 11:27:21
I am fairly certain that the issue is that the jquery bindings set to run on $(document).ready do not have the fixture html available to them. So when my events occur that are intended to make a change to the DOM via a jquery function, nothing happens, and my tests fail. I saw a "solution" to this problem here , but that solution which did work for me, required changing my working jquery function to bind with the .live method instead of the .click method. I have two issue with this. First I do not want to have to change my working code so that the tests will pass properly. The testing

How to do TDD with hardware

前提是你 提交于 2019-11-30 11:06:28
问题 All the projects I work interface to a piece of hardware and this is often the main purpose of the software. Are there any effective ways I can apply TDD to the code that works with the hardware? Update: Sorry for not being clearer with my question. The hardware I use is a frame grabber that capture images from a camera. I then process these images, display them and save them to disk. I can simulate all the processing that takes place after the images are captured by using previously captured

Mocking virtual readonly properties with moq

ぐ巨炮叔叔 提交于 2019-11-30 10:43:30
I couldn't find a way to do this, though this can be done by hand so why not with moq? Given this class public abstract class MyAbstraction { public virtual string Foo { get { return "foo"; } } } you can set up Foo (a read-only property) like this: var stub = new Mock<MyAbstraction>(); stub.SetupGet(x => x.Foo).Returns("bar"); stub.Object.Foo will now return "bar" instead of "foo". 来源: https://stackoverflow.com/questions/1454186/mocking-virtual-readonly-properties-with-moq

The Agile Way: Integration Testing vs Functional Testing or both? [closed]

有些话、适合烂在心里 提交于 2019-11-30 10:16:52
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I work in an office which has been doing Agile for a while now. We use Scrum for project management and mix in the engineering

How do I run a function before each test when using qUnit?

感情迁移 提交于 2019-11-30 09:06:10
What is the equivalent of nUnits [SetUp] attribute for qUnit? Perry Tew Registering a QUnit Callback var mySetupFunc(details){/* setup code */} QUnit.testStart(mySetupFunc); Callback Details As of QUnit version 1.10.0pre-A, each registered callback will receive a hash as the first (and only) parameter. I've named mine 'details' in the example above. The contents of the hash vary by callback. Here's a list of information in each hash. begin (start of all tests) {} /* empty hash */ done (end of all tests) failed: (int) total tests failed passed: (int) total tests passed total: (int) total tests