随笔分类 -  Unit Testing

摘要:For example, we want to test against a implemataion: We want to do the test with Java Context: 1. Bring in some dependencies: in pom.xml Create a new 阅读全文
posted @ 2019-04-24 15:14 Zhentiw 阅读(400) 评论(0) 推荐(0)
摘要:In this post, we are going to see more functionalities in Mockito. Mock a List interface: Call multi times: First call, return 10, second times return 阅读全文
posted @ 2019-04-23 20:25 Zhentiw 阅读(850) 评论(0) 推荐(0)
摘要:Previously we have seen how to do Unit testing with Mockito; In this post, we are going to see, using annotation from Mockito to make testing easier: 阅读全文
posted @ 2019-04-18 20:23 Zhentiw 阅读(309) 评论(0) 推荐(0)
摘要:We have the implemetion: And we want to test agaisnst it: 阅读全文
posted @ 2019-04-17 17:52 Zhentiw 阅读(181) 评论(0) 推荐(0)
摘要:Check the get started guid https://junit.org/junit5/docs/current/user-guide/#overview-getting-help 阅读全文
posted @ 2019-04-16 17:44 Zhentiw 阅读(145) 评论(0) 推荐(0)
摘要:For some React component testing, we have common setup in each test file: We want to setup a common place for JEST to load those scripts: Then for com 阅读全文
posted @ 2019-04-15 14:54 Zhentiw 阅读(177) 评论(0) 推荐(0)
摘要:Thanks to react-testing-library our tests are free of implementation details, so when we refactor components to hooks we generally don't need to make 阅读全文
posted @ 2019-02-19 22:53 Zhentiw 阅读(1218) 评论(0) 推荐(0)
摘要:Sometimes when writing a unit test, you know that the module you're testing imports a module that you would like to observe, or at the very least mock 阅读全文
posted @ 2019-01-03 18:10 Zhentiw 阅读(400) 评论(0) 推荐(0)
摘要:Run Jest Watch Mode by default locally with is-ci-cli In CI, we don’t want to start the tests in watch mode, but locally we normally want to run the t 阅读全文
posted @ 2018-11-30 02:59 Zhentiw 阅读(600) 评论(0) 推荐(0)
摘要:HTML: Component Controller: Testing: 阅读全文
posted @ 2018-11-22 19:56 Zhentiw 阅读(621) 评论(0) 推荐(0)
摘要:Setup an afterEach Test Hook for all tests with Jest setupTestFrameworkScriptFile With our current test situation, we have a commonality between most 阅读全文
posted @ 2018-11-21 04:32 Zhentiw 阅读(832) 评论(0) 推荐(0)
摘要:The component test: 阅读全文
posted @ 2018-11-14 17:06 Zhentiw 阅读(264) 评论(0) 推荐(0)
摘要:Most of time, when we want to test function call inside a promise, we can do: It is important to call 'done()', otherwise, the code won't call the pro 阅读全文
posted @ 2018-11-14 16:52 Zhentiw 阅读(255) 评论(0) 推荐(0)
摘要:Transpile Modules with Babel in Jest Tests Jest automatically loads and applies our babel configuration. However, because our project takes advantage 阅读全文
posted @ 2018-11-14 02:53 Zhentiw 阅读(928) 评论(0) 推荐(0)
摘要:Ensure Functions are Called Correctly with JavaScript Mocks Often when writing JavaScript tests and mocking dependencies, you’ll want to verify that t 阅读全文
posted @ 2018-11-06 04:25 Zhentiw 阅读(437) 评论(0) 推荐(0)
摘要:The static code analysis and linting tool ESLint is the de-facto standard for linting JavaScript projects. In this lesson we’ll see how to install, ru 阅读全文
posted @ 2018-11-04 03:36 Zhentiw 阅读(362) 评论(0) 推荐(0)
摘要:In this lesson, we’ll get the most fundamental understanding of what an automated test is in JavaScript. A test is code that throws an error when the 阅读全文
posted @ 2018-10-25 01:58 Zhentiw 阅读(652) 评论(0) 推荐(0)
摘要:When testing functions that make HTTP requests, it's not preferable for those requests to actually run. Using the nock JavaScript library, we can mock 阅读全文
posted @ 2018-10-20 04:00 Zhentiw 阅读(194) 评论(0) 推荐(0)
摘要:Unit testing functions that invoke callbacks can require a lot of setup code. Using sinon.spy to create a fake callback function can simplify your uni 阅读全文
posted @ 2018-09-19 02:54 Zhentiw 阅读(173) 评论(0) 推荐(0)
摘要:Jest is a fantastic testing library, but maybe you've been putting off the switch because migrating all of your existing tests from another library se 阅读全文
posted @ 2018-08-22 01:10 Zhentiw 阅读(355) 评论(0) 推荐(0)