Logo

dev-resources.site

for different kinds of informations.

Smth about Unittests

Published at
11/21/2024
Categories
testing
unittest
cpp
productivity
Author
junissen
Categories
4 categories in total
testing
open
unittest
open
cpp
open
productivity
open
Author
8 person written this
junissen
open
Smth about Unittests

When we need to improve some path of code, I recommend to write UnitTests.
Programming includes 4 stadies:

  • Math modeling future decision + flowchart
  • Coding each part of decision in a some language
  • Compiling all code with Visual Studio/Online
  • Testing software product + UserTests

using namespace System;
using namespace System::Text;
using namespace System::Collections::Generic;
using namespace Microsoft::VisualStudio::TestTools::UnitTesting;

Each libraries provides path to success in testing and create a good environment for variables.
Namespace constitude an area, where values and functions will be viewed by user for understanding: ok tests/or not.

int power(int a, int b, int n) {// a^b mod n
            int tmp = a;
            int sum = tmp;
            for (int i = 1; i < b; i++) {
                for (int j = 1; j < a; j++) {
                    sum += tmp;
                    if (sum >= n) {
                        sum -= n;
                    }
                }
                tmp = sum;
            }
            return tmp;
        }
Enter fullscreen mode Exit fullscreen mode

Using breakpoints I can watch in output-window temporary result of finishing fuction. Its help to avoid hard analytics work under final output of full programme.

void TestMethod1()
        {
            string message_in, messagge_out;
            vector<pair<int, int> > cypher;

            cout << "Enter your message: " << endl;
            getline(cin, message_in);

            int x = rand() % (593 - 2) + 1;

            crypt(593, 123, x, message_in, cypher);
            decrypt(593, x, cypher, messagge_out);

            String^ str1 = gcnew String(message_in.c_str());
            String^ str2 = gcnew String(messagge_out.c_str());
            Assert::AreEqual(str1, str2, true);
        }
Enter fullscreen mode Exit fullscreen mode

Writing UnitTests makes reading code more loyal to the reviewer in company. I think, not testers, but developers need to write simple Unittests. Becouse only developers knows some special variables and values in programme.

unittest Article's
30 articles in total
Favicon
Getting Started with Android Testing: Building Reliable Apps with Confidence (Part 1/3)
Favicon
What is the Order of Importance for Unit, Integration, and Acceptance Tests in Software Development?
Favicon
Top 17 Best Unit Testing Tools
Favicon
JUnit Testing: A Comprehensive Guide to Unit Testing in Java
Favicon
Crafting Effective Unit Tests for Generative AI Applications
Favicon
Harder, Better, Faster, Stronger Tests With Fixtures
Favicon
How To Test Your JavaScript Application With Jest Framework?
Favicon
Effective Strategies for Writing Unit Tests with External Dependencies like Databases and APIs
Favicon
Debugging Laravel Routes in Testing
Favicon
Is Unit Test really a MUST?
Favicon
Let's Learn Unit Testing in Python with pytest! ๐Ÿš€
Favicon
An opinionated testing approach for VueJS
Favicon
PHP: Should I mock or should I go?
Favicon
Implementing Unit Testing in ReadmeGenie
Favicon
8.Angular Unit Testing: A Step-by-Step Approach
Favicon
โ€œWhy Unit Testing Is Not an Option, But a Dutyโ€
Favicon
Early Raises $5M to Transform Software Development
Favicon
Smth about Unittests
Favicon
Unit Testing in Laravel: A Practical Approach for Developers
Favicon
Assert with Grace: Custom Soft Assertions using AssertJ for Cleaner Code
Favicon
Writing Integration And Unit Tests for a Simple Fast API application using Pytest
Favicon
End-To-End Testing for Java+React Applications
Favicon
Writing XUnit Tests without Object Arrays
Favicon
Comprehensive Testing in .NET 8: Using Moq and In-Memory Databases
Favicon
Test-Driven Development (TDD) in Front-end.
Favicon
Unit testing
Favicon
jUnit - Testes unitรกrios em Java
Favicon
Testing Spring Boot Applications: Unit, Integration, and Mocking โ€” A Comprehensive Guide
Favicon
Letโ€™s Make Jest Run Much Faster
Favicon
Test-Driven Development

Featured ones: