1. 程式人生 > >Ask HN: How do you write tests when feature toggles are involved?

Ask HN: How do you write tests when feature toggles are involved?

Hey, I am working on an application and I started using feature toggles recently. I'm not sure how to test my code (both unit and integration/service test) for all the states of the toggle.

For unit tests I duplicated my test cases and patched the feature toggle checker to return either true or false (depending on the test case). The plan is to remove the test cases for the "off" toggle case when I remove the code. The downside of this approach is that number of test cases grows exponentially with the number of toggles we use.

For integration/acceptance tests I plan to build a framework to somehow enable/disable the toggle for a user (maybe using an HTTP header to override the toggle value).

Are you using any other approaches?

相關推薦

Ask HN: How do you write tests when feature toggles are involved?

Hey, I am working on an application and I started using feature toggles recently. I'm not sure how to test my code (both unit and integration/service test)

Ask HN: How do you notify your readers when you blog?

In the past I have allowed readers to provide their email address to receive new-post notifications, however I discontinued this as I don't want the respon

Ask HN: How do you know when to switch teams within your company?

I'm wondering how folks here suss out when the right time to switch teams/projects might be. How do you identify when you've learned all you can from a eng

Ask HN: How do you decide when you've done enough work for the day?

I'm a relatively junior software engineer, a little over a year out from university, with a cushy remote job working for big-co. And I never know how much

Ask HN: How do you deal with complain rate on SES

Hi all,I run a news letter with AWS SES and the complaint rate is reaching 0.05%. They expect 0.1% complaint rate.I have received zero complaints email fro

Ask HN: How do you stay fresh on the basics of computer science?

I had an uncomfortable experience last week where I realized I'd forgotten the basics of condition variables (in particular, how to prevent the thundering

Ask HN: How do you spend time during compilation?

I feel it's a significant problem when compilation lasts for more than 10s>. To not get bored, I am jumping into random articles during that time, loos

Ask HN: How do you measure your funnel?

We are working on a tool to help people measure their conversion funnels. For example:Unique visitors to website -> User Signups -> Paid CustomersTh

Ask HN: How do you handle user money that you have to return

I am thinking about building a system where customers would put money into their account and they can use there balance to purchase things. Whats the best

Ask HN: How do you become the best at something?

I realized that while I'm fairly competent at some things, I'm not really top percentile in anything save my ability to communicate. It's really weighing o

Ask HN: How do you market yourself at your mid

Hello folks,I have a weird situation and if you don't mind, I would like to ask for your advice.I'm having hard time getting hired, both onsite and remotel

Ask HN: How do you organize your stuff?

So, I'm having an issue right now that is accruing rapidly. I have a lot of documents, images, pdfs, videos, code snippets, files, etc, etc that I have tri

Ask HN: How do you manage a security policy for your small team?

My company is a small team operating in the digital health space that's recently grown to 12 in the past year. Although we don't deal with a ton of PHI, s

Ask HN: How do you deal with papers behind paywalls?

I'm beginning a self-study quest on computer vision. Unfortunately, I've learned that a lot of the less popular papers are not available for free download

Ask HN: How do you relate to the (negative) feedback you get in annual reviews?

Annual performance reviews seem to be an necessary evil in the corporate world. Sometimes I feel the feedback I get is taken out of context and I can have

Ask HN: How do you feel about having a mentor in your line of work?

Hello HN-ers I've been in the software industry for about five years and have worked as an individual contributor at companies big and small. Over the year

Ask HN: How do you automate your server provisioning?

My goal is to fully automate spinning up servers/environments, with, for example, a MySQL installation with users/data. I would like to automate this provi

Ask HN: How do you help your kids with schoolwork?

How do you help your kids with their schooling (beyond homework)?I'm interested in things that you feel advance their understanding of math, sciences etc.M

Ask HN: How do you manage your day

Work environment and needs are very personal but maybe you can learn from my solution.My frustration with most task manager is that they require me to manu

Ask HN: How do you avoid tech addiction yet still stay up to date?

After just now reading an article about tech addiction, I thought I'd pose the question (which I consider so often) to HN to find out what you're doing. It