Why separate unit tests into an assembly [closed]

I primarily develop in .Net, and have been playing around with F#. It’s a nice concise language, but I’m just using it for throwaway code currently. I’ve taken to sitting my tests in the same file as the main code that I’m writing.

I am under the unexamined opinion that this is done so that we don’t have testing code floating around in production, and that we have separate dependencies for testing which we don’t want to go to production.

This has raised the question for me: why do we traditionally separate out test assemblies and not just use conditional compilation?

4

Unit testing can involve a number of different libraries and dependancies than the application that is associated with it.

Thinking of an application I recently wrote as a proof of concept (Java) – a simple CRUD app with unit tests against an in memory database.

WebApp | Unit Test
-------+----------
       | JUnit
       | Mockito
Tomcat | Jetty
Mysql  | HSqldb

So in the web app, I’m just linking against Tomcat and Mysql. Within the Unit testing I’ve got JUnit, Mockito, Jetty, and HSqldb that are being used. So its more than just conditional compilation to try to remove, its also the various testing frameworks that are used that you don’t want linked in with the main application. Mockito, Junit, Jetty and HSqldb have no place at all in the production application – why include them as part of the linking and deployment for it?

When working with Maven (again Java), the directory structure looks like:

my-app
|-- pom.xml
`-- src
    |-- main
    |   `-- java
    |   |   `-- com
    |   |       `-- mycompany
    |   |           `-- app
    |   |               `-- App.java
    |   `resources
    |
    `-- test
        `-- java
        |   `-- com
        |       `-- mycompany
        |           `-- app
        |               `-- AppTest.java
        `resources

The resources directories are where one has the dependency injection information so that when the test runs, the test resources are used (allowing one to have the connection to the in memory database instead of production).

This structure also prevents AppTest from getting compiled in with the main application. Or any of the resources for testing to get compiled in. The build process doesn’t even see the test directory. Thus, the code that is tested is identical to the code that is deployed.

That last bit is the key – the code that is tested being the same as the code being deployed. I remember my days back in college with some C code that had #ifdef DEBUG scattered through it, and on occasion there was code in there that had a side effect. I’d take the debug off, and it wouldn’t work. Debug on, its fine. The same issue exists with conditional compilation. It can exist with testing too (if you start tinkering in the guts of the module while testing it, but this becomes harder to do bad practice because its easier to do it the right way.

The other bit is even if this code isn’t code that you can invoke easily – having testing code of any sort in deployed code means that a malicious user may be able to find that function to invoke, or entry point to call that now exposes something you shouldn’t let users get at.

It is normal to have a build server with a very well control version of the compiler etc on it that builds the software, runs the tests and if the tests pass creates the installer using the same dlls that were tested.

There is an additional risk of configuration errors if the software is built in a different way for testing then for shipping.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Why separate unit tests into an assembly [closed]

I primarily develop in .Net, and have been playing around with F#. It’s a nice concise language, but I’m just using it for throwaway code currently. I’ve taken to sitting my tests in the same file as the main code that I’m writing.

I am under the unexamined opinion that this is done so that we don’t have testing code floating around in production, and that we have separate dependencies for testing which we don’t want to go to production.

This has raised the question for me: why do we traditionally separate out test assemblies and not just use conditional compilation?

4

Unit testing can involve a number of different libraries and dependancies than the application that is associated with it.

Thinking of an application I recently wrote as a proof of concept (Java) – a simple CRUD app with unit tests against an in memory database.

WebApp | Unit Test
-------+----------
       | JUnit
       | Mockito
Tomcat | Jetty
Mysql  | HSqldb

So in the web app, I’m just linking against Tomcat and Mysql. Within the Unit testing I’ve got JUnit, Mockito, Jetty, and HSqldb that are being used. So its more than just conditional compilation to try to remove, its also the various testing frameworks that are used that you don’t want linked in with the main application. Mockito, Junit, Jetty and HSqldb have no place at all in the production application – why include them as part of the linking and deployment for it?

When working with Maven (again Java), the directory structure looks like:

my-app
|-- pom.xml
`-- src
    |-- main
    |   `-- java
    |   |   `-- com
    |   |       `-- mycompany
    |   |           `-- app
    |   |               `-- App.java
    |   `resources
    |
    `-- test
        `-- java
        |   `-- com
        |       `-- mycompany
        |           `-- app
        |               `-- AppTest.java
        `resources

The resources directories are where one has the dependency injection information so that when the test runs, the test resources are used (allowing one to have the connection to the in memory database instead of production).

This structure also prevents AppTest from getting compiled in with the main application. Or any of the resources for testing to get compiled in. The build process doesn’t even see the test directory. Thus, the code that is tested is identical to the code that is deployed.

That last bit is the key – the code that is tested being the same as the code being deployed. I remember my days back in college with some C code that had #ifdef DEBUG scattered through it, and on occasion there was code in there that had a side effect. I’d take the debug off, and it wouldn’t work. Debug on, its fine. The same issue exists with conditional compilation. It can exist with testing too (if you start tinkering in the guts of the module while testing it, but this becomes harder to do bad practice because its easier to do it the right way.

The other bit is even if this code isn’t code that you can invoke easily – having testing code of any sort in deployed code means that a malicious user may be able to find that function to invoke, or entry point to call that now exposes something you shouldn’t let users get at.

It is normal to have a build server with a very well control version of the compiler etc on it that builds the software, runs the tests and if the tests pass creates the installer using the same dlls that were tested.

There is an additional risk of configuration errors if the software is built in a different way for testing then for shipping.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Why separate unit tests into an assembly [closed]

I primarily develop in .Net, and have been playing around with F#. It’s a nice concise language, but I’m just using it for throwaway code currently. I’ve taken to sitting my tests in the same file as the main code that I’m writing.

I am under the unexamined opinion that this is done so that we don’t have testing code floating around in production, and that we have separate dependencies for testing which we don’t want to go to production.

This has raised the question for me: why do we traditionally separate out test assemblies and not just use conditional compilation?

4

Unit testing can involve a number of different libraries and dependancies than the application that is associated with it.

Thinking of an application I recently wrote as a proof of concept (Java) – a simple CRUD app with unit tests against an in memory database.

WebApp | Unit Test
-------+----------
       | JUnit
       | Mockito
Tomcat | Jetty
Mysql  | HSqldb

So in the web app, I’m just linking against Tomcat and Mysql. Within the Unit testing I’ve got JUnit, Mockito, Jetty, and HSqldb that are being used. So its more than just conditional compilation to try to remove, its also the various testing frameworks that are used that you don’t want linked in with the main application. Mockito, Junit, Jetty and HSqldb have no place at all in the production application – why include them as part of the linking and deployment for it?

When working with Maven (again Java), the directory structure looks like:

my-app
|-- pom.xml
`-- src
    |-- main
    |   `-- java
    |   |   `-- com
    |   |       `-- mycompany
    |   |           `-- app
    |   |               `-- App.java
    |   `resources
    |
    `-- test
        `-- java
        |   `-- com
        |       `-- mycompany
        |           `-- app
        |               `-- AppTest.java
        `resources

The resources directories are where one has the dependency injection information so that when the test runs, the test resources are used (allowing one to have the connection to the in memory database instead of production).

This structure also prevents AppTest from getting compiled in with the main application. Or any of the resources for testing to get compiled in. The build process doesn’t even see the test directory. Thus, the code that is tested is identical to the code that is deployed.

That last bit is the key – the code that is tested being the same as the code being deployed. I remember my days back in college with some C code that had #ifdef DEBUG scattered through it, and on occasion there was code in there that had a side effect. I’d take the debug off, and it wouldn’t work. Debug on, its fine. The same issue exists with conditional compilation. It can exist with testing too (if you start tinkering in the guts of the module while testing it, but this becomes harder to do bad practice because its easier to do it the right way.

The other bit is even if this code isn’t code that you can invoke easily – having testing code of any sort in deployed code means that a malicious user may be able to find that function to invoke, or entry point to call that now exposes something you shouldn’t let users get at.

It is normal to have a build server with a very well control version of the compiler etc on it that builds the software, runs the tests and if the tests pass creates the installer using the same dlls that were tested.

There is an additional risk of configuration errors if the software is built in a different way for testing then for shipping.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Why separate unit tests into an assembly [closed]

I primarily develop in .Net, and have been playing around with F#. It’s a nice concise language, but I’m just using it for throwaway code currently. I’ve taken to sitting my tests in the same file as the main code that I’m writing.

I am under the unexamined opinion that this is done so that we don’t have testing code floating around in production, and that we have separate dependencies for testing which we don’t want to go to production.

This has raised the question for me: why do we traditionally separate out test assemblies and not just use conditional compilation?

4

Unit testing can involve a number of different libraries and dependancies than the application that is associated with it.

Thinking of an application I recently wrote as a proof of concept (Java) – a simple CRUD app with unit tests against an in memory database.

WebApp | Unit Test
-------+----------
       | JUnit
       | Mockito
Tomcat | Jetty
Mysql  | HSqldb

So in the web app, I’m just linking against Tomcat and Mysql. Within the Unit testing I’ve got JUnit, Mockito, Jetty, and HSqldb that are being used. So its more than just conditional compilation to try to remove, its also the various testing frameworks that are used that you don’t want linked in with the main application. Mockito, Junit, Jetty and HSqldb have no place at all in the production application – why include them as part of the linking and deployment for it?

When working with Maven (again Java), the directory structure looks like:

my-app
|-- pom.xml
`-- src
    |-- main
    |   `-- java
    |   |   `-- com
    |   |       `-- mycompany
    |   |           `-- app
    |   |               `-- App.java
    |   `resources
    |
    `-- test
        `-- java
        |   `-- com
        |       `-- mycompany
        |           `-- app
        |               `-- AppTest.java
        `resources

The resources directories are where one has the dependency injection information so that when the test runs, the test resources are used (allowing one to have the connection to the in memory database instead of production).

This structure also prevents AppTest from getting compiled in with the main application. Or any of the resources for testing to get compiled in. The build process doesn’t even see the test directory. Thus, the code that is tested is identical to the code that is deployed.

That last bit is the key – the code that is tested being the same as the code being deployed. I remember my days back in college with some C code that had #ifdef DEBUG scattered through it, and on occasion there was code in there that had a side effect. I’d take the debug off, and it wouldn’t work. Debug on, its fine. The same issue exists with conditional compilation. It can exist with testing too (if you start tinkering in the guts of the module while testing it, but this becomes harder to do bad practice because its easier to do it the right way.

The other bit is even if this code isn’t code that you can invoke easily – having testing code of any sort in deployed code means that a malicious user may be able to find that function to invoke, or entry point to call that now exposes something you shouldn’t let users get at.

It is normal to have a build server with a very well control version of the compiler etc on it that builds the software, runs the tests and if the tests pass creates the installer using the same dlls that were tested.

There is an additional risk of configuration errors if the software is built in a different way for testing then for shipping.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật