Questions tagged [white-box]

White-box testing is a method of testing software that tests internal structures or workings of an application as opposed to its functionality i.e. black-box testing

43 questions
31
votes
4 answers

PHPUnit: Doing assertions on non-public variables

Suppose I have a class with a private property and associated public getter and setter. I want to test with PHPUnit that the property gets the correct value after the setter has been used or that the getter returns the correct property. Of course I…
GordonM
  • 31,179
  • 15
  • 87
  • 129
19
votes
4 answers

Unit testing, Black-box testing and white box testing

What is Unit testing, Black-box testing and White-Box testing? I googled but all the explanation I found was very technical. Can anyone answer this question in a simple way with an appropriate example?
software
  • 728
  • 6
  • 18
  • 39
11
votes
3 answers

Control flow graph & cyclomatic complexity for following procedure

insertion_procedure (int a[], int p [], int N) { int i,j,k; for (i=0; i<=N; i++) p[i] = i; for (i=2; i<=N; i++) { k = p[i]; j = 1; while (a[p[j-1]] > a[k]) {p[j] = p[j-1]; j--} p[j] = k; } } I…
AJ.
  • 2,561
  • 9
  • 46
  • 81
7
votes
1 answer

When is it appropriate to bypass encapsulation in unit tests?

I've recently become aware of powermock's Whitebox functionality. (In summary, it allows you to directly test private methods or modify private members directly from unit tests--while keeping them private!) I know that there are some frames of…
LimaNightHawk
  • 6,613
  • 3
  • 41
  • 60
6
votes
8 answers

What is black box testing and white box testing

I'm trying to understand one in terms of how it compares to the other. Is white box testing where you can see the code and black box testing where you don't look at the code?
neuromancer
  • 53,769
  • 78
  • 166
  • 223
5
votes
3 answers

Is it possible to mock a single method in an already existing object?

For an integration test, I need to mock a specific method in a java service client without destroying the rest of the information in it. It has no self-constructor, so a solution like this is out of the question: private DBClient mockClient = new…
AdamSpurgin
  • 951
  • 2
  • 8
  • 28
5
votes
2 answers

Is JUnit black-box or white-box testing?

Is JUnit black-box or white-box testing? I think that it is white-box but i am not sure. I am looking for that but I can't find a clear answer. Even a simple discussion about that would be useful.
anna
  • 745
  • 2
  • 9
  • 30
4
votes
1 answer

Does statement coverage count false if statements?

When checking statement coverage for my code: double programme(double x, double y) { double z if(x>=5){ z = 15; } else if(x>=3){ z= 10; } else { z=0; } if (y>z) { z=y; } return…
Cormac Hallinan
  • 187
  • 1
  • 12
3
votes
6 answers

Should I use "glass box" testing when it leads to *fewer* tests?

For example, I'm writing tests against a CsvReader. It's a simple class that enumerates and splits rows of text. Its only raison d'être is ignoring commas within quotes. It's less than a page. By "black box" testing the class, I've checked things…
harpo
  • 41,820
  • 13
  • 96
  • 131
3
votes
1 answer

Unit test private class in Objective-C

How do you unit test a private class in Objective-C? Is it possible when both the @interface and the @implementation of the class are included in a .m implementation file? Refactoring the interface of the private class into its own header is not…
hpique
  • 119,096
  • 131
  • 338
  • 476
3
votes
2 answers

Java whitebox testing

How is white box testing done on java applications? Does it mean that I have to test class by class? From my research I know that: White Box Testing is a software testing method in which the internal structure/design/implementation of the item…
knowbody
  • 8,106
  • 6
  • 45
  • 70
2
votes
3 answers

How do I mock a private static final field initialized via a private constructor using Powermock and Mockito?

Here's my source class - public class ClassToTest extends AbstractSuperClass { private static final ClassToTest INSTANCE = new ClassToTest(); // (line 1) need to mock this variable static ClassToTest get() { return…
seeker
  • 6,841
  • 24
  • 64
  • 100
2
votes
1 answer

How do I use Powermock's Whitebox.invokeMethod(Object instance, Object... arguments) when my first method parameter is String type?

I would like to not explicitly name the method I am invoking in the invokeMethod() arguments. Powermock offers an overloaded invokeMethod() that infers the method based on the parameters passed. invokeMethod(Object instance, Object...…
pluralMonad
  • 313
  • 1
  • 2
  • 7
2
votes
1 answer

Why doesn't Whitebox recognize my private method?

I have a method that I am trying to test in a public final class called MyUtil: private static String getStringFromArray(String[] array) { String tempString = ""; if (array != null && array.length > 0) { for (int i = 0; i <…
user3897392
  • 397
  • 2
  • 5
  • 22
2
votes
1 answer

Why is not safe to use java.lang.ThreadGroup?

I´m looking for best practices and I´m applying PMD to my Java EE Project, but one rule says that I have to avoid using java.lang.ThreadGroup, and I´m using it right now. The rule says that is not safe, and I want to know: Why? Thanks
Ocepeda
  • 37
  • 5
1
2 3