Day 27: Testing
Day 27: Testing
+ 0 comments C++
class TestDataEmptyArray{ public: static vector<int> get_array(){ return {}; } }; class TestDataUniqueValues{ public: static vector<int> get_array(){ return {1, 2, 3}; } static int get_expected_result(){ return 0; } }; class TestDataExactlyTwoDifferentMinimums{ public: static vector<int> get_array(){ return {1, 2, 1}; }
static int get_expected_result(){ return 0;
} };
+ 1 comment In serarching I see about three or four people asking for this task to be explained. I also feel this task is difficult to understand what you are supposed to do. It sort of seems like the purpose might be to get you to come up with good test cases that might actually test edge cases? It is unclear, there is no tutorial linked and although I have both 1) written unit tests before and 2) dveloped a test plan with specific test cases, it is not clear what is meant. It is also confusing that this is the first challenget that doens't say "write your code here".
+ 0 comments class TestDataEmptyArray: def get_array(): return [] class TestDataUniqueValues: def get_array(): return [1,2] def get_expected_result(): return int (0) class TestDataExactlyTwoDifferentMinimums: def get_array(): return [1,1] def get_expected_result(): return int (0)
+ 0 comments Python 3
Pythonista! This is very good case to demonstrate your OOP skills. Make your test class valuable for real business case:
- generate the list with randmo shift and length
- shuffle the list
- control number of duplicates
- make random sampling reproducible (use
randmo.seed()
)
from random import seed, sample, randint seed(250) class TestDataEmptyArray: static_array: list[int] = [] @classmethod def get_array(cls) -> list[int]: return cls.static_array class TestDataUniqueValues(TestDataEmptyArray): static_min_val = randint(0,1000) static_array_ordered: list[int] = [i for i in range(static_min_val, static_min_val*100)] static_array: list[int] = sample(static_array_ordered, len(static_array_ordered)) @classmethod def get_expected_result(cls) -> int: return cls.static_array.index(cls.static_min_val) class TestDataExactlyTwoDifferentMinimums(TestDataUniqueValues): static_min_val= randint(0,1000) static_array_ordered: list[int] = [i for i in range(static_min_val, static_min_val*100)] + [static_min_val] static_array: list[int] = sample(static_array_ordered, len(static_array_ordered))
Happy pythoning!
🦁
+ 0 comments It's actually way more complicated than I could imagine. I understand that it's important for proper business workflow, but in my case, working with specialists turned out to be a less demanding option. I've read about Payment system integration from Process MIX, and working with these specialists provided me with the best solution for my business.
Sort 204 Discussions, By:
Please Login in order to post a comment