'프로그래밍/JAVA'에 해당되는 글 3건

  1. 2014.03.15 about test layer
  2. 2013.08.05 java goto문 1
  3. 2013.04.25 Map 읽기 전용으로 만들기

#define It is a my subjective opinion. :)

(Maybe you can see many broken English.. please don't surprise, instead, let me know about the incorrect part. )



Why we need test?

 

Of course, we need test to verify the functions we made are right.


it's includes the real environment.

 

I used to do JUnit test and try to many abnormal methods to verify functions. 

(of course, I always thinking "how can i do test better?")


And I admit the facts below.

 

1. most of all, i want to test which use external resources. 


(in fact, i can get peaceful mind when this test was finished)

 

This test includes many resources such as network, database, and so on.


i'm usually did unit-test for this test.

 

2. For example, when i want to check some data in DB, but data not exist at first time.


Therefore, the insert operations are needed before select operation. however, can we confident that insert operation is success?


If so, how about insert some data to DB manually? (this way is... look so little complex or dirty..)

 

3. I can't think about test layer well.

 

Recently i realized that test have some layers and the below layer's object can be substituted by "mock".

 

So, what is test layer? 


Above picture is appeared in my brain.

 

There are two parts, one is needed test in real environment, another one is can be substituted by mock.


So, i like to summarized below as a result.

 

  • Unit Test: the tests are processed at each layer. and below layers are substituted by mock. 
  • Integration Test: the tests are use external resources. real environment required to do this test. 

And this is what i want to get by test,

 

Check your business logic and program structure by "Unit Test", check your real environment(resources) by "Integration Test"

Link

it is a really good article: The correct way to use integration tests in your build process


'프로그래밍 > JAVA' 카테고리의 다른 글

java goto문  (1) 2013.08.05
Map 읽기 전용으로 만들기  (0) 2013.04.25
Posted by DevMoon
,

JAVA에서 2개 루프를 빠져나가려 하다가 goto문이 있나 검색해봤는데 같은 효과를 내는게 있었다. -_-;


출처: Is there a goto statement in java?


loops:
for (int i = 0; i < MAX_I; i++) {
    for (int j = 0; j < MAX_J; j++) {
        // do stuff
        break loops;
    }
}

굿잡~!


슈퍼맨

'프로그래밍 > JAVA' 카테고리의 다른 글

about test layer  (0) 2014.03.15
Map 읽기 전용으로 만들기  (0) 2013.04.25
Posted by DevMoon
,

method에서 map을 생성하자니 비효율적인 구조라는 의견이 있고


class로 빼자니, 다른 method에서 조작을 방지했으면 좋겠다는 의견이 있어 생각하다가 발견했다.


(어떤 정신나간 개발자가 method에서 이상한 값을 put 하는 그런 상황)


// class 변수
private final Map<string,string> MyMap;
...
// 생성자에서
HashMap<string,string> map = new HashMap<string,string>();
map.put("K", "1000");
map.put("M", "1000000");
MyMap = Collections.unmodifiableMap(map);


이와 같이 해주면 MyMap에 put 연산할 경우 예외가 발생하게 된다. (java.lang.UnSupportedOperation )


컴파일 시에 에러를 내주면 좋으련만..


이렇게 해도 경각심은 줄 수 있을 것같다.


참고 한 곳(링크) : How to create read only List, Map and Set in Java – unmodifiable example


생각중

'프로그래밍 > JAVA' 카테고리의 다른 글

about test layer  (0) 2014.03.15
java goto문  (1) 2013.08.05
Posted by DevMoon
,