Вопрос

I ve been reading for the whitebox and blackbox testing.

If im not wrong:

Whitebox tests the implementation of a Software Program, but blackbox tests the inputs and outputs.

Can someone please give me an example of a simple code for the both cases?

Thank you in advance.

so, the code here is a blackbox testing?

  class Schalter
  {
     private boolean
     {
       private boolean _istAn;
       public Schalter(boolean anfangsAn)
       {
          _istAn = anfangsAn;        
       }       
       public boolean istAn()
       {
          return _istAn;
       }   
       public void umschalten()
       {
         _istAn = !_istAn;
       }
  }
Это было полезно?

Решение

Blackbox -> you're really just checking if you're getting correct output for the input you gave your program.

Say you have a prompt that asks you to enter 2 digits to get the sum of the numbers.

Enter 2 numbers: 2 5 output: 2 + 5 = 7

That's all there is to black box really.


White box you would want to check to see HOW it's happening.

You could do the normal thing which would be something like

int adder(int firstNum, int secondNum)
{ 
    return firstNum + secondNum;
}

this is more efficient than say something like:

int adder(int firstNum, int secondNum)
{
    int temp;
    for(int i = 0; i < (firstNum + secondNum + 1); i++)
        temp = i;
    return temp;
}

In whitebox testing you would look at your code and figure out which is more efficient and/or is easier to read. Obviously the first one is since:

  1. the code is simpler and easier to understand
  2. The first does not involve loops to find the answer this takes up more processing time than the first
  3. The first doesn't create extra variables that are not needed. This means less memory needed to keep track of the data.

This is a simple and arbitrary example, but when you get into larger projects you'll do a lot of whitebox testing when you do unit tests to figure out if smaller segments of your code works and you would normally do black box testing when you start integrating the smaller segments of your code into the larger project to check if you were still getting correct output for given input.

Another way to look at it you could use blackbox testing to see if you were getting bad output and if so then you could go in and do whitebox testing to see what you were doing wrong in your code.

Другие советы

Blackbox testing is a way of testing where you don't care how the program manipulates the input; you're only checking to see if the outputs are valid for the specified inputs.

Whitebox testing is a way of testing when you care how the program manipulates the input, as well as the output.

I guess one example is if you were writing a test for sorting algorithims. A blackbox test would simply check to see if the outputs are sorted according to what you would expect. A whitebox test might check to see if the sorting is stable or not, because that depends on the implementation of the sorting algorithm. For example, Merge Sort is stable, whereas the typical in-place version of Quicksort is not (although stable versions do exist).

See in simple words, White box testing is a testing where you are aware of the inner paths and coding of software or any app. Programming skills are needed to design Test Cases in White box testing. White box testing can be performed in Unit testing, Integration testing and System testing.

While in Black Box testing you just need SRS(Software Requirement Specification) to understand what system does and what are Client's requirement. Here tester's Programming skills are not tested. Usually in Manual testing BlackBox approach is followed. Black Box testing is done in almost all levels i.e Unit testing, Integration testing , System testing and Acceptance testing.

In Black box testing the structure of the program is not considered. Test cases are decided solely on the basis of the requirements or specification of the program or module, and the internals of the program are not considered for the selection of the test cases. black box testing is concerned with functionality of the program.

Lifted from https://in.answers.yahoo.com/question/index?qid=20101031090207AAbYHrB

White box testing is the detailed investigation of internal logic and structure of the code. White box testing is also called glass testing or open box testing. In order to perform white box testing on an application, the tester needs to possess knowledge of the internal working of the code.

Lifted from http://www.tutorialspoint.com/software_testing/testing_methods.htm

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top