Java programming test. Program testing, JUnit. Test Suites, JUnit Suite, SuiteClasses
I believe that software development is more than a job. I see myself as a craftsman who tries to become better every day. The "easiest" way to do this is to find several good tools and answer the following questions:
- When should I use Tool X?
- How should I use tool X?
Automated testing is a very important part of software development, but there are few posts on programmers' blogs about the tools used. This same article will allow you to look into my “tool box”. I'll cover 12 libraries and frameworks that I use to write unit and integration tests, and provide links to pages that will help you understand how to use them.
Let's look in my toolbox
Before you can use the tools described below, you must set up a build that automatically runs integration and unit tests. I have 2 notes on this topic:
- Integration Testing with Maven describes how we can set up a Maven build with integration and unit tests in different directories.
- Getting Started with Gradle: Integration Testing with the TestSets Plugin covers the same for Gradle.
Now you're ready to take a closer look at my tools. I've divided them into categories to make it easier for you to navigate.
So, here are 12 tools that I use for integration and unit testing.
Running tests
AssertJ provides a flexible API for writing assertions with useful error messages, improves the readability of test code, and allows you to turn tests into executable specifications that adhere to the desired domain-specific language.
Additionally:
- Using Hamcrest in Testing covers how to use Hamcrest to write tests, as well as how to extend its capabilities with custom modules.
- Turning Assertions into a Domain-Specific Language explains how to create custom assertions in AssertJ.
- Writing Clean Tests: Replacing Assertions with Domain-Specific Language. Explains why we should replace JUnit's standard assertions with our own that use proper domain-specific language.
Data Access Code Testing
A fast database, useful for writing integration tests that run on the developer’s local machine.
An extension to JUnit that can be used to initialize the database to a known state before running each integration test and populate the database with the necessary data. DbUnit has its shortcomings, but it is a very useful tool for separating test data and test code.
Additionally:
- describes the key components of DbUnit that you need to know to write tests using DbUnit.
- provides five rules for writing the best tests for data access code.
While looking for test tasks for Java programmers, I came across an interesting site (Avast users should not go, a script Trojan is detected, others are apparently fine) - http://www.betterprogrammer.com. It tests the qualifications of Java programmers in the simplest way, but in an automatic way: offering to write several functions (methods) of increasing complexity and copy the code into the TextArea. Next, the site engine does something with the tasks (no less than a unit test), calculates a certain qualification index based on the “speed-quality” criteria and gives the final score in the following form:
Then the questions begin. I myself programmed in Java for the second time in my life (and therefore simply skipped complex tasks), so 82% on this test correspond to the level non-java programmer. How much, then, should Java Junior, Java Programmer, and even more so Java Senior recruit?! What result can you expect from present java programmer - 90, 95, 99? And finally, what if the “programmer” scores less than 82, but nevertheless applies for some kind of job?!
Java is an object-oriented, strongly typed programming language developed by Sun Microsystems in 1991. The language was originally called Oak and was intended for programming consumer electronics, but was later renamed Java. The official release of Java in 1995 was very successful and soon after Java language has taken a strong position as a tool for developing server applications.
Nowadays, Java is used in all areas of development. software - server applications, desktop applications, tools, web applications - all are developed using Java and related technologies.
Target audience of the Java test
The Java test contains questions that most developers with minimal Java programming experience will know the answers to. The test will be useful to many, including people who do not have much experience with Java and want to gain a minimal understanding of basic concepts this popular programming language. This test can also be useful for students studying Java to consolidate knowledge acquired at universities or as a result of independent work.
Java Test Prerequisites
It is assumed that before taking the Java Fundamentals test, you already know the basic concepts such as “variable”, “loop”, “method” and know the syntax of basic language constructs. If this is not the case, we recommend that you first familiarize yourself with the basics of Java by reading an introductory course.
Java Test Structure
The Java - Fundamentals test covers the following topics:
You can read more about the topics of the test questions below:
- Objects and classes: questions in this topic cover concepts such as a class, an instance of a class (object), constructors, methods and class fields.
- Syntax: Questions in this section will test knowledge keywords language, operators, basic types (primitives, String), control constructs (if-else, while, for), as well as an understanding of exception handling (Exception).
- Other: This section contains questions regarding basic concepts, terms and abbreviations, naming conventions for classes, variables and methods. This section also covers questions about files (.java, .class, .jar) and packages, life cycle objects, garbage collection (garbage collection).
Walkthrough online test Java helps you test and consolidate your knowledge java basics, and also leads you to take more difficult tests from the Java tests section.
We hope that this test will be useful and entertaining for you.
Further development of the Java test
The Java test is constantly updated with new questions.
The Quizful team's immediate plans include creating expert-level tests in Java. Perhaps a Java Puzzlers test will be created, but unfortunately it is very slowly filled with questions.
If you have any comments about the test questions, be sure to write to us. Good luck.