How can cover project (obj) using junit in maven project? - unit-testing

I am writing test cases using maven,and junit.
One problem I found is that my test case not cover process(obj)

Related

How to include my testable project in my Unit test project

I'm trying to create a unit test in QTCreator so I've followed this tutorial from the QT Docs:
https://doc.qt.io/qt-6/qttestlib-tutorial1-example.html
This runs example fine for me.
Unfortunately, this tutorial, and a few others I've found all give examples referencing classes included within the Unit Test project itself. But I would have thought the proper way would be to use my Unit Test project to create tests for the separate actual application that I'm trying to test. (after all, I can't add QTEST_MAIN to my own project as it has its own main).
So how do I include the testable in the unit test project and refer to the functions that I am trying to test?

Is it safe to use the set of unit testing frameworks in the same project?

Visual Studio
I use NUnit in my project with unit tests. But I need some tests to write with using JustMock and NSubstitute frameworks. I want to have one project with the tests for each my tested project. I.e. I don't want to have the individual project with tests for each unit framework (NUnit, JustMock and NSubstitute). Will I have the problems (for example, conflicts with their test adapters) if my tests will be in a single project?
NUnit is a testing framework. NSubstitute is a mocking framework. From the name, I suppose JustMock is also a mocking framework. Testing frameworks and mocking frameworks are different things, so they don't generally conflict.
Between two different mocking frameworks, it's possible but not likely to have conflicts. I think most of them would show up at compile time, in case the framework uses the same names and you are using both namespaces in a file.
It will be easier to answer, however, if you have some specific concerns.

How to explicitly exclude assemblies in test runner during TFS Build

In my solution I have c++ and c# projects with corresponding Unit test projects mixed. During a TFS build I only want to execute the C# unit tests. Unfortunately I can't find a way to exclude these test assemblies to be being used in the unit test runner. I could identify all c++ unit tests projects based on a naming patter like Native.Tests.dll.
I can't find a way to explicitly exclude certain test assemblies from being tested/executed from the test runner.
Is there a way through either
Test Case Filter
Test assembly file specification?
Environment:
TFS 2013
Process template: ReleaseTfvcTemplate.12.xaml
In case you are wondering: Why do I want to exclude certain assemblies?
I want to use the Test Category feature to exclude certain unit tests from being executed on the build server, which you do through the TestCaseFilter feature in the TFS template. You specify that per "Test batch". When I run all my unit tests (c# + c++) in one test settings the native unit tests throw an error, because they don't understand/support the TestCategory-filter feature (remember: Test Case Filter). Therefore I want to split the it in 2 test runs/batches: c++ and c#.
Test Category is only worked in C# test project. (Test in my environment: TFS2015 VS2015)
If you only want to execute the C# unit test. The simplest way you can specify the C# test assembly file in Test assembly file specification.
You just need to identify all C# unit tests projects based on a naming patter totally different as C++ tests projects.
Note: You must make sure you are using totally different naming rules between C++ an C# test project.
For example:
C++test project name : including ABC like ABC1 ,ABC2, ABC3
C# test project name: including XYZ like XYZ1, XYZ2 ,XYZ3
Then using ***XYZ*.dll in Test assembly file specification to run the all C# test project.

Should I create a separate project to do Unit Test? I'm using JUnit

I'm new to software testing. I want to use JUnit to do the unit test on a Java project. The project is open source and it's a small application. So my question is - should I create a separate project to do testing or write the test code within the project? I use Netbeans btw. Also, can I generate test cases from existing class? On Netbeans, when you click File->New File->Unit Tests(Choose File Type)->Test for existing class, you are probably supposed to generate a test file but it turns out that you will just create new empty file... at least on my laptop... I'm not sure if that's the problem of the IDE..
Anyway, any answers would be appreciated. Thanks.
I suggest you use Maven's default project structure:
<projectDir>
<src>
<main>
<java>
<packages>
<test>
<java>
<packages>
In this structure your tests are in the same project as your code but to not get compiled into your jar. Generally you put a unit test in the same package (under src/test/java) as the class under test. This gives organization and allows the unit test to access package-private (default scope) methods.

Is it possible to integrate c++ unit tests into a maven build process and if yes with which unit testing framework

We are planning to integrate our native c++ projects into a maven build process. Further we want to formulate unit tests that are run automatically using the standard maven syntax (as for java unit tests) also for the c++ projects. Is this possible with c++ unit testing frameworks and if yes, which framework integrates well with maven ?
I would suggest to take a deep look into the maven-nar-plugin in relationship with Boost library which should fit your needs.