Black and White Test techniques in practice

Hi All,

I’m looking for code examples explaining how to apply different white and black box test techniques in practice? Any recommendation ?

1 Like

Hi there,

Basically any unit test example is an example of a white box technique and commonly web UI tests in selenium tend to be black boxier. Automation in general is always a shade of grey due to that applications in general is designed for humans. So you need to work on a more code aware layer for the computer to be able to interact with the application. The JAutomate and image based tools is as far as I know the least application aware tools when working with UIs. When working with APIs your automation can utilize black box techniques more. Code wise they do not look that different tho as they are generally a list of instructions and then some assertions.

I also prefer to look at is at the level of integration rather than white box / black box when discussing levels in automation where unit test is the least integrated part (typically none) and end-to-end the most integrated type of testing. And as a general rule your strategy should aim to have the most coverage for unit tests and the least in e2e due to their cost.

To explain the different is that in unit tests you tend to replace any external dependency with mocks that just give you what you want instead of integrating them with other parts. Where black box only uses what inputs and outputs that are available to the user of the application.

Hope it helps to find what you are looking for.

When using black box tests, you are testing without reference to how the code is written. You should build based upon the specification only. When a change is made internally that affects how the app responds, it is important that the test breaks. This is your guard against accidentally changing the external behaviour.
Code wise, the black box test must not use the internal classes and models or an internal change may not trigger a failure.

White box techniques use knowledge of the implementation. Unit testing is an example of whitebox testing, but also static code analysis to identify code smells and patterns that suggest security risks are very useful white box approaches.

Thank You for your answers, what I really meant isn’t the difference between what we use in each techniques. I want to make a link with techniques in ISTQB foundation level like (state transition testing, equivalence partitionning, …for black box techniques) and branch decision testing, path testing for white box testing
How to implement effective test cases using those techniques?

I do not know of any such examples. And I think it would service you better to consider test automation techniques as additional techniques rather than automatic implementation of such techniques. There are for instance a several techniques in Model Based Testing, like Finite State Machines, Decision Trees, Pair Wise Testing which is based on the same principles. Since of certain problems computers are way faster they application of them are different. To take Pair Wise Testing, the principle is that we want to reduce the number of inputs to a smaller number, similar to Equivalence Class Partitioning (ECP). But instead of reasoning that the number 2 and number 4 is the same class in an input field for a number. Pair wise is reducing the number of inputs to make sure that the number of combinations at least covers all pairs. While we can do that computation manually a computer is way faster at it, which lends itself as a new option that we can bring into our test strategy.
Further there are many instances where your choice of what to automate and how is impacted by the same techniques. Such as ECP where you will typically use that technique in automation to determine what inputs to use. Or if you have a very stateful system with a lot of state transitions it is better to apply Finite State Machines than scripted sequences used in Unit Tests. Similar to Pair Wise automation also allows you to not use these techniques. Such as High Volume Automated Testing allows to ignore ECP and try all cases instead.

tl;dr automation allows for additional techniques rather than implementing manual ones

2 Likes

Thanks a lot for your helpful answer :blush:

1 Like

Concerning the test techniques, I have two training courses on these topics with more details than in other typical training, some examples included.

This one is on white-box test techniques -

And this is about the black-box test techniques -

1 Like