Best Assertj code snippet using org.assertj.core.api.assumptions.BDDAssumptionsTest.AtomicInteger
Source:BDDAssumptionsTest.java
...48import java.util.concurrent.CompletableFuture;49import java.util.concurrent.CompletionStage;50import java.util.concurrent.Future;51import java.util.concurrent.atomic.AtomicBoolean;52import java.util.concurrent.atomic.AtomicInteger;53import java.util.concurrent.atomic.AtomicIntegerArray;54import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;55import java.util.concurrent.atomic.AtomicLong;56import java.util.concurrent.atomic.AtomicLongArray;57import java.util.concurrent.atomic.AtomicLongFieldUpdater;58import java.util.concurrent.atomic.AtomicMarkableReference;59import java.util.concurrent.atomic.AtomicReference;60import java.util.concurrent.atomic.AtomicReferenceArray;61import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;62import java.util.concurrent.atomic.AtomicStampedReference;63import java.util.function.DoublePredicate;64import java.util.function.IntPredicate;65import java.util.function.LongPredicate;66import java.util.function.Predicate;67import java.util.stream.DoubleStream;68import java.util.stream.IntStream;69import java.util.stream.LongStream;70import java.util.stream.Stream;71import org.junit.jupiter.api.BeforeEach;72import org.junit.jupiter.api.Nested;73import org.junit.jupiter.api.Test;74/**75 * Tests for <code>{@link org.assertj.core.api.BDDAssumptions}</code>.76 *77 * @author Gonzalo Müller78 */79class BDDAssumptionsTest {80 @Nested81 class BDDAssumptions_given_boolean_primitive_Test {82 private final boolean actual = true;83 @Test84 void should_run_test_when_assumption_passes() {85 thenCode(() -> given(actual).isTrue()).doesNotThrowAnyException();86 }87 @Test88 void should_ignore_test_when_assumption_fails() {89 expectAssumptionNotMetException(() -> given(actual).isFalse());90 }91 }92 @Nested93 class BDDAssumptions_given_Boolean_Test {94 private final Boolean actual = true;95 @Test96 void should_run_test_when_assumption_passes() {97 thenCode(() -> given(actual).isTrue()).doesNotThrowAnyException();98 }99 @Test100 void should_ignore_test_when_assumption_fails() {101 expectAssumptionNotMetException(() -> given(actual).isFalse());102 }103 }104 @Nested105 class BDDAssumptions_given_boolean_array_Test {106 private final boolean[] actual = { true, true };107 @Test108 void should_run_test_when_assumption_passes() {109 thenCode(() -> given(actual).contains(true)).doesNotThrowAnyException();110 }111 @Test112 void should_ignore_test_when_assumption_fails() {113 expectAssumptionNotMetException(() -> given(actual).contains(false));114 }115 }116 @Nested117 class BDDAssumptions_given_byte_primitive_Test {118 private final byte actual = (byte) 1;119 @Test120 void should_run_test_when_assumption_passes() {121 thenCode(() -> given(actual).isOne()).doesNotThrowAnyException();122 }123 @Test124 void should_ignore_test_when_assumption_fails() {125 expectAssumptionNotMetException(() -> given(actual).isZero());126 }127 }128 @Nested129 class BDDAssumptions_given_Byte_Test {130 private final Byte actual = (byte) 1;131 @Test132 void should_run_test_when_assumption_passes() {133 thenCode(() -> given(actual).isOne()).doesNotThrowAnyException();134 }135 @Test136 void should_ignore_test_when_assumption_fails() {137 expectAssumptionNotMetException(() -> given(actual).isZero());138 }139 }140 @Nested141 class BDDAssumptions_given_byte_array_Test {142 private final byte[] actual = { 1, 2 };143 @Test144 void should_run_test_when_assumption_passes() {145 thenCode(() -> given(actual).contains((byte) 1)).doesNotThrowAnyException();146 }147 @Test148 void should_ignore_test_when_assumption_fails() {149 expectAssumptionNotMetException(() -> given(actual).contains((byte) 0));150 }151 }152 @Nested153 class BDDAssumptions_given_short_primitive_Test {154 private final short actual = (short) 1;155 @Test156 void should_run_test_when_assumption_passes() {157 thenCode(() -> given(actual).isOne()).doesNotThrowAnyException();158 }159 @Test160 void should_ignore_test_when_assumption_fails() {161 expectAssumptionNotMetException(() -> given(actual).isZero());162 }163 }164 @Nested165 class BDDAssumptions_given_Short_Test {166 private final Short actual = (short) 1;167 @Test168 void should_run_test_when_assumption_passes() {169 thenCode(() -> given(actual).isOne()).doesNotThrowAnyException();170 }171 @Test172 void should_ignore_test_when_assumption_fails() {173 expectAssumptionNotMetException(() -> given(actual).isZero());174 }175 }176 @Nested177 class BDDAssumptions_given_short_array_Test {178 private final short[] actual = { 1, 2 };179 @Test180 void should_run_test_when_assumption_passes() {181 thenCode(() -> given(actual).contains((short) 1)).doesNotThrowAnyException();182 }183 @Test184 void should_ignore_test_when_assumption_fails() {185 expectAssumptionNotMetException(() -> given(actual).contains((short) 0));186 }187 }188 @Nested189 class BDDAssumptions_given_int_Test {190 private final int actual = 1;191 @Test192 void should_run_test_when_assumption_passes() {193 thenCode(() -> given(actual).isOne()).doesNotThrowAnyException();194 }195 @Test196 void should_ignore_test_when_assumption_fails() {197 expectAssumptionNotMetException(() -> given(actual).isZero());198 }199 }200 @Nested201 class BDDAssumptions_given_Integer_Test {202 private final Integer actual = 1;203 @Test204 void should_run_test_when_assumption_passes() {205 thenCode(() -> given(actual).isOne()).doesNotThrowAnyException();206 }207 @Test208 void should_ignore_test_when_assumption_fails() {209 expectAssumptionNotMetException(() -> given(actual).isZero());210 }211 }212 @Nested213 class BDDAssumptions_given_int_array_Test {214 private final int[] actual = { 1, 2 };215 @Test216 void should_run_test_when_assumption_passes() {217 thenCode(() -> given(actual).contains(1)).doesNotThrowAnyException();218 }219 @Test220 void should_ignore_test_when_assumption_fails() {221 expectAssumptionNotMetException(() -> given(actual).contains(0));222 }223 }224 @Nested225 class BDDAssumptions_given_BigInteger_Test {226 private final BigInteger actual = BigInteger.valueOf(1L);227 @Test228 void should_run_test_when_assumption_passes() {229 thenCode(() -> given(actual).isOne()).doesNotThrowAnyException();230 }231 @Test232 void should_ignore_test_when_assumption_fails() {233 expectAssumptionNotMetException(() -> given(actual).isZero());234 }235 }236 @Nested237 class BDDAssumptions_given_long_primitive_Test {238 private final long actual = 1L;239 @Test240 void should_run_test_when_assumption_passes() {241 thenCode(() -> given(actual).isOne()).doesNotThrowAnyException();242 }243 @Test244 void should_ignore_test_when_assumption_fails() {245 expectAssumptionNotMetException(() -> given(actual).isZero());246 }247 }248 @Nested249 class BDDAssumptions_given_Long_Test {250 private final Long actual = 1L;251 @Test252 void should_run_test_when_assumption_passes() {253 thenCode(() -> given(actual).isOne()).doesNotThrowAnyException();254 }255 @Test256 void should_ignore_test_when_assumption_fails() {257 expectAssumptionNotMetException(() -> given(actual).isZero());258 }259 }260 @Nested261 class BDDAssumptions_given_long_array_Test {262 private final long[] actual = { 1, 2 };263 @Test264 void should_run_test_when_assumption_passes() {265 thenCode(() -> given(actual).contains(1L)).doesNotThrowAnyException();266 }267 @Test268 void should_ignore_test_when_assumption_fails() {269 expectAssumptionNotMetException(() -> given(actual).contains(0L));270 }271 }272 @Nested273 class BDDAssumptions_given_float_primitive_Test {274 private final float actual = 1.0f;275 @Test276 void should_run_test_when_assumption_passes() {277 thenCode(() -> given(actual).isOne()).doesNotThrowAnyException();278 }279 @Test280 void should_ignore_test_when_assumption_fails() {281 expectAssumptionNotMetException(() -> given(actual).isZero());282 }283 }284 @Nested285 class BDDAssumptions_given_Float_Test {286 private final Float actual = 1.0f;287 @Test288 void should_run_test_when_assumption_passes() {289 thenCode(() -> given(actual).isOne()).doesNotThrowAnyException();290 }291 @Test292 void should_ignore_test_when_assumption_fails() {293 expectAssumptionNotMetException(() -> given(actual).isZero());294 }295 }296 @Nested297 class BDDAssumptions_given_float_array_Test {298 private final float[] actual = { 1.0f, 2.0f };299 @Test300 void should_run_test_when_assumption_passes() {301 thenCode(() -> given(actual).contains(1.0f)).doesNotThrowAnyException();302 }303 @Test304 void should_ignore_test_when_assumption_fails() {305 expectAssumptionNotMetException(() -> given(actual).contains(0.0f));306 }307 }308 @Nested309 class BDDAssumptions_given_double_primitive_Test {310 private final double actual = 1.0;311 @Test312 void should_run_test_when_assumption_passes() {313 thenCode(() -> given(actual).isOne()).doesNotThrowAnyException();314 }315 @Test316 void should_ignore_test_when_assumption_fails() {317 expectAssumptionNotMetException(() -> given(actual).isZero());318 }319 }320 @Nested321 class BDDAssumptions_given_Double_Test {322 private final Double actual = 1.0;323 @Test324 void should_run_test_when_assumption_passes() {325 thenCode(() -> given(actual).isOne()).doesNotThrowAnyException();326 }327 @Test328 void should_ignore_test_when_assumption_fails() {329 expectAssumptionNotMetException(() -> given(actual).isZero());330 }331 }332 @Nested333 class BDDAssumptions_given_double_array_Test {334 private final double[] actual = { 1.0, 2.0 };335 @Test336 void should_run_test_when_assumption_passes() {337 thenCode(() -> given(actual).contains(1.0)).doesNotThrowAnyException();338 }339 @Test340 void should_ignore_test_when_assumption_fails() {341 expectAssumptionNotMetException(() -> given(actual).contains(0.0f));342 }343 }344 @Nested345 class BDDAssumptions_given_BigDecimal_Test {346 private final BigDecimal actual = BigDecimal.valueOf(1.0);347 @Test348 void should_run_test_when_assumption_passes() {349 thenCode(() -> given(actual).isOne()).doesNotThrowAnyException();350 }351 @Test352 void should_ignore_test_when_assumption_fails() {353 expectAssumptionNotMetException(() -> given(actual).isZero());354 }355 }356 @Nested357 class BDDAssumptions_given_char_Test {358 private final char actual = 'A';359 @Test360 void should_run_test_when_assumption_passes() {361 thenCode(() -> given(actual).isUpperCase()).doesNotThrowAnyException();362 }363 @Test364 void should_ignore_test_when_assumption_fails() {365 expectAssumptionNotMetException(() -> given(actual).isLowerCase());366 }367 }368 @Nested369 class BDDAssumptions_given_Character_Test {370 private final Character actual = 'A';371 @Test372 void should_run_test_when_assumption_passes() {373 thenCode(() -> given(actual).isUpperCase()).doesNotThrowAnyException();374 }375 @Test376 void should_ignore_test_when_assumption_fails() {377 expectAssumptionNotMetException(() -> given(actual).isLowerCase());378 }379 }380 @Nested381 class BDDAssumptions_given_char_array_Test {382 private final char[] actual = { 'A', 'B' };383 @Test384 void should_run_test_when_assumption_passes() {385 thenCode(() -> given(actual).contains('A')).doesNotThrowAnyException();386 }387 @Test388 void should_ignore_test_when_assumption_fails() {389 expectAssumptionNotMetException(() -> given(actual).contains('C'));390 }391 }392 @Nested393 class BDDAssumptions_given_CharSequence_Test {394 private final CharSequence actual = "Yoda";395 @Test396 void should_run_test_when_assumption_passes() {397 thenCode(() -> given(actual).isNotEmpty()).doesNotThrowAnyException();398 }399 @Test400 void should_ignore_test_when_assumption_fails() {401 expectAssumptionNotMetException(() -> given(actual).isNullOrEmpty());402 }403 }404 @Nested405 class BDDAssumptions_given_String_Test {406 private final String actual = "Yoda";407 @Test408 void should_run_test_when_assumption_passes() {409 thenCode(() -> given(actual).isEqualTo("Yoda")).doesNotThrowAnyException();410 }411 @Test412 void should_ignore_test_when_assumption_fails() {413 expectAssumptionNotMetException(() -> given(actual).isNullOrEmpty());414 }415 }416 @Nested417 class BDDAssumptions_given_StringBuilder_Test {418 private final StringBuilder actual = new StringBuilder("Yoda");419 @Test420 void should_run_test_when_assumption_passes() {421 thenCode(() -> given(actual).isNotEmpty()).doesNotThrowAnyException();422 }423 @Test424 void should_ignore_test_when_assumption_fails() {425 expectAssumptionNotMetException(() -> given(actual).isNullOrEmpty());426 }427 }428 @Nested429 class BDDAssumptions_given_StringBuffer_Test {430 private final StringBuffer actual = new StringBuffer("Yoda");431 @Test432 void should_run_test_when_assumption_passes() {433 thenCode(() -> given(actual).isNotEmpty()).doesNotThrowAnyException();434 }435 @Test436 void should_ignore_test_when_assumption_fails() {437 expectAssumptionNotMetException(() -> given(actual).isNullOrEmpty());438 }439 }440 @Nested441 class BDDAssumptions_given_Class_Test {442 private final Class<?> actual = Number.class;443 @Test444 void should_run_test_when_assumption_passes() {445 thenCode(() -> given(actual).isAssignableFrom(Long.class)).doesNotThrowAnyException();446 }447 @Test448 void should_ignore_test_when_assumption_fails() {449 expectAssumptionNotMetException(() -> given(actual).isInterface());450 }451 }452 @Nested453 class BDDAssumptions_given_generics_Test {454 private class Yoda {455 private int field = 1;456 @SuppressWarnings("unused")457 public int getField() {458 return field;459 }460 }461 @Nested462 class BDDAssumptions_given_T_Test {463 private final Yoda actual = new Yoda();464 @Test465 void should_run_test_when_assumption_passes() {466 thenCode(() -> given(actual).hasNoNullFieldsOrProperties()).doesNotThrowAnyException();467 }468 @Test469 void should_ignore_test_when_assumption_fails() {470 expectAssumptionNotMetException(() -> given(actual).hasAllNullFieldsOrProperties());471 }472 }473 @Nested474 class BDDAssumptions_given_array_T_Test {475 private final Yoda[] actual = { new Yoda(), new Yoda() };476 @Test477 void should_run_test_when_assumption_passes() {478 thenCode(() -> given(actual).isNotEmpty()).doesNotThrowAnyException();479 }480 @Test481 void should_ignore_test_when_assumption_fails() {482 expectAssumptionNotMetException(() -> given(actual).isNullOrEmpty());483 }484 }485 @Nested486 class BDDAssumptions_givenObject_Test {487 private final Yoda actual = new Yoda();488 @Test489 void should_run_test_when_assumption_passes() {490 thenCode(() -> givenObject(actual).hasNoNullFieldsOrProperties()).doesNotThrowAnyException();491 }492 @Test493 void should_ignore_test_when_assumption_fails() {494 expectAssumptionNotMetException(() -> givenObject(actual).hasAllNullFieldsOrProperties());495 }496 }497 }498 @Nested499 class BDDAssumptions_given_Comparable_Test {500 private class Yoda implements Comparable<Yoda> {501 @Override502 public int compareTo(Yoda to) {503 return 0;504 }505 }506 private final Yoda actual = new Yoda();507 @Test508 void should_run_test_when_assumption_passes() {509 thenCode(() -> given(actual).isEqualByComparingTo(new Yoda())).doesNotThrowAnyException();510 }511 @Test512 void should_ignore_test_when_assumption_fails() {513 expectAssumptionNotMetException(() -> given(actual).isNotEqualByComparingTo(new Yoda()));514 }515 }516 @Nested517 class BDDAssumptions_given_Throwable_Test {518 private final Throwable actual = new Exception("Yoda time");519 @Test520 void should_run_test_when_assumption_passes() {521 thenCode(() -> given(actual).hasMessage("Yoda time")).doesNotThrowAnyException();522 }523 @Test524 void should_ignore_test_when_assumption_fails() {525 expectAssumptionNotMetException(() -> given(actual).hasMessage(""));526 }527 }528 @Nested529 class BDDAssumptions_givenCode_Test {530 @Nested531 class BDDAssumptions_givenCode_no_exception_required_Test {532 @Test533 void should_run_test_when_assumption_passes() {534 thenCode(() -> givenCode(() -> { /* some code */ }).doesNotThrowAnyException()).doesNotThrowAnyException();535 }536 @Test537 void should_ignore_test_when_assumption_fails() {538 expectAssumptionNotMetException(() -> givenCode(() -> { /* some code */ }).hasMessage("Yoda time"));539 }540 }541 @Nested542 class BDDAssumptions_givenCode_exception_required_Test {543 @Test544 void should_run_test_when_assumption_passes() {545 thenCode(() -> givenCode(() -> {546 throw new Exception("Yoda time");547 }).hasMessage("Yoda time")).doesNotThrowAnyException();548 }549 @Test550 void should_ignore_test_when_assumption_fails() {551 expectAssumptionNotMetException(() -> givenCode(() -> {552 throw new Exception("Yoda time");553 }).doesNotThrowAnyException());554 }555 }556 }557 @Nested558 class BDDAssumptions_given_Iterable_Test {559 private final Iterable<Integer> actual = Arrays.asList(1, 2);560 @Test561 void should_run_test_when_assumption_passes() {562 thenCode(() -> given(actual).contains(2)).doesNotThrowAnyException();563 }564 @Test565 void should_ignore_test_when_assumption_fails() {566 expectAssumptionNotMetException(() -> given(actual).containsOnly(2));567 }568 }569 @Nested570 class BDDAssumptions_given_Iterator_Test {571 private final Iterator<Integer> actual = Arrays.asList(1, 2).iterator();572 @Test573 void should_run_test_when_assumption_passes() {574 thenCode(() -> given(actual).hasNext()).doesNotThrowAnyException();575 }576 @Test577 void should_ignore_test_when_assumption_fails() {578 expectAssumptionNotMetException(() -> given(actual).isExhausted());579 }580 }581 @Nested582 class BDDAssumptions_given_List_Test {583 private final List<Integer> actual = Arrays.asList(1, 2);584 @Test585 void should_run_test_when_assumption_passes() {586 thenCode(() -> given(actual).contains(2)).doesNotThrowAnyException();587 }588 @Test589 void should_ignore_test_when_assumption_fails() {590 expectAssumptionNotMetException(() -> given(actual).containsOnly(2));591 }592 }593 @Nested594 class BDDAssumptions_given_Map_Test {595 private final Map<Integer, Integer> actual = Collections.singletonMap(1, 2);596 @Test597 void should_run_test_when_assumption_passes() {598 thenCode(() -> given(actual).containsEntry(1, 2)).doesNotThrowAnyException();599 }600 @Test601 void should_ignore_test_when_assumption_fails() {602 expectAssumptionNotMetException(() -> given(actual).containsEntry(2, 1));603 }604 }605 @Nested606 class BDDAssumptions_given_Predicate_Test {607 private final Predicate<Integer> actual = value -> value > 0;608 @Test609 void should_run_test_when_assumption_passes() {610 thenCode(() -> given(actual).accepts(1, 2)).doesNotThrowAnyException();611 }612 @Test613 void should_ignore_test_when_assumption_fails() {614 expectAssumptionNotMetException(() -> given(actual).accepts(-2, -1));615 }616 }617 @Nested618 class BDDAssumptions_given_IntPredicate_Test {619 private final IntPredicate actual = value -> value > 0;620 @Test621 void should_run_test_when_assumption_passes() {622 thenCode(() -> given(actual).accepts(1, 2)).doesNotThrowAnyException();623 }624 @Test625 void should_ignore_test_when_assumption_fails() {626 expectAssumptionNotMetException(() -> given(actual).accepts(-2, -1));627 }628 }629 @Nested630 class BDDAssumptions_given_LongPredicate_Test {631 private final LongPredicate actual = value -> value > 0;632 @Test633 void should_run_test_when_assumption_passes() {634 thenCode(() -> given(actual).accepts(1, 2)).doesNotThrowAnyException();635 }636 @Test637 void should_ignore_test_when_assumption_fails() {638 expectAssumptionNotMetException(() -> given(actual).accepts(-2, -1));639 }640 }641 @Nested642 class BDDAssumptions_given_DoublePredicate_Test {643 private final DoublePredicate actual = value -> value > 0;644 @Test645 void should_run_test_when_assumption_passes() {646 thenCode(() -> given(actual).accepts(1.0, 2.0)).doesNotThrowAnyException();647 }648 @Test649 void should_ignore_test_when_assumption_fails() {650 expectAssumptionNotMetException(() -> given(actual).accepts(-2.0, -1.0));651 }652 }653 @Nested654 class BDDAssumptions_given_Optional_Test {655 private final Optional<?> actual = Optional.empty();656 @Test657 void should_run_test_when_assumption_passes() {658 thenCode(() -> given(actual).isEmpty()).doesNotThrowAnyException();659 }660 @Test661 void should_ignore_test_when_assumption_fails() {662 expectAssumptionNotMetException(() -> given(actual).isNotEmpty());663 }664 }665 @Nested666 class BDDAssumptions_given_OptionalInt_Test {667 private final OptionalInt actual = OptionalInt.empty();668 @Test669 void should_run_test_when_assumption_passes() {670 thenCode(() -> given(actual).isEmpty()).doesNotThrowAnyException();671 }672 @Test673 void should_ignore_test_when_assumption_fails() {674 expectAssumptionNotMetException(() -> given(actual).isNotEmpty());675 }676 }677 @Nested678 class BDDAssumptions_given_OptionalLong_Test {679 private final OptionalLong actual = OptionalLong.empty();680 @Test681 void should_run_test_when_assumption_passes() {682 thenCode(() -> given(actual).isEmpty()).doesNotThrowAnyException();683 }684 @Test685 void should_ignore_test_when_assumption_fails() {686 expectAssumptionNotMetException(() -> given(actual).isNotEmpty());687 }688 }689 @Nested690 class BDDAssumptions_given_OptionalDouble_Test {691 private final OptionalDouble actual = OptionalDouble.empty();692 @Test693 void should_run_test_when_assumption_passes() {694 thenCode(() -> given(actual).isEmpty()).doesNotThrowAnyException();695 }696 @Test697 void should_ignore_test_when_assumption_fails() {698 expectAssumptionNotMetException(() -> given(actual).isNotEmpty());699 }700 }701 @Nested702 class BDDAssumptions_given_Stream_Test {703 private final Stream<Integer> actual = Stream.of(1, 2);704 @Test705 void should_run_test_when_assumption_passes() {706 thenCode(() -> given(actual).contains(2)).doesNotThrowAnyException();707 }708 @Test709 void should_ignore_test_when_assumption_fails() {710 expectAssumptionNotMetException(() -> given(actual).containsOnly(2));711 }712 }713 @Nested714 class BDDAssumptions_given_IntStream_Test {715 private final IntStream actual = IntStream.of(1, 2);716 @Test717 void should_run_test_when_assumption_passes() {718 thenCode(() -> given(actual).contains(2)).doesNotThrowAnyException();719 }720 @Test721 void should_ignore_test_when_assumption_fails() {722 expectAssumptionNotMetException(() -> given(actual).containsOnly(2));723 }724 }725 @Nested726 class BDDAssumptions_given_LongStream_Test {727 private final LongStream actual = LongStream.of(1L, 2L);728 @Test729 void should_run_test_when_assumption_passes() {730 thenCode(() -> given(actual).contains(2L)).doesNotThrowAnyException();731 }732 @Test733 void should_ignore_test_when_assumption_fails() {734 expectAssumptionNotMetException(() -> given(actual).containsOnly(2L));735 }736 }737 @Nested738 class BDDAssumptions_given_DoubleStream_Test {739 private final DoubleStream actual = DoubleStream.of(1.0, 2.0);740 @Test741 void should_run_test_when_assumption_passes() {742 thenCode(() -> given(actual).contains(2.0)).doesNotThrowAnyException();743 }744 @Test745 void should_ignore_test_when_assumption_fails() {746 expectAssumptionNotMetException(() -> given(actual).containsOnly(2.0));747 }748 }749 @Nested750 class BDDAssumptions_given_Spliterator_Test {751 private final Spliterator<Integer> actual = Stream.of(1, 2).spliterator();752 @Test753 void should_run_test_when_assumption_passes() {754 thenCode(() -> given(actual).hasCharacteristics(Spliterator.SIZED)).doesNotThrowAnyException();755 }756 @Test757 void should_ignore_test_when_assumption_fails() {758 expectAssumptionNotMetException(() -> given(actual).hasCharacteristics(Spliterator.DISTINCT));759 }760 }761 @Nested762 class BDDAssumptions_given_Future_Test {763 private final Future<Integer> actual = mock(Future.class);764 @BeforeEach765 void beforeEach() {766 willReturn(true).given(actual).isCancelled();767 }768 @Test769 void should_run_test_when_assumption_passes() {770 thenCode(() -> given(actual).isCancelled()).doesNotThrowAnyException();771 }772 @Test773 void should_ignore_test_when_assumption_fails() {774 expectAssumptionNotMetException(() -> given(actual).isNotCancelled());775 }776 }777 @Nested778 class BDDAssumptions_given_CompletableFuture_Test {779 private final CompletableFuture<Integer> actual = CompletableFuture.completedFuture(1);780 @Test781 void should_run_test_when_assumption_passes() {782 thenCode(() -> given(actual).isDone()).doesNotThrowAnyException();783 }784 @Test785 void should_ignore_test_when_assumption_fails() {786 expectAssumptionNotMetException(() -> given(actual).isNotDone());787 }788 }789 @Nested790 class BDDAssumptions_given_CompletableStage_Test {791 private final CompletionStage<Integer> actual = CompletableFuture.completedFuture(1);792 @Test793 void should_run_test_when_assumption_passes() {794 thenCode(() -> given(actual).isDone()).doesNotThrowAnyException();795 }796 @Test797 void should_ignore_test_when_assumption_fails() {798 expectAssumptionNotMetException(() -> given(actual).isNotDone());799 }800 }801 @Nested802 class BDDAssumptions_given_AtomicBoolean_Test {803 private final AtomicBoolean actual = new AtomicBoolean(true);804 @Test805 void should_run_test_when_assumption_passes() {806 thenCode(() -> given(actual).isTrue()).doesNotThrowAnyException();807 }808 @Test809 void should_ignore_test_when_assumption_fails() {810 expectAssumptionNotMetException(() -> given(actual).isFalse());811 }812 }813 @Nested814 class BDDAssumptions_given_AtomicInteger_Test {815 private final AtomicInteger actual = new AtomicInteger(1);816 @Test817 void should_run_test_when_assumption_passes() {818 thenCode(() -> given(actual).hasNonNegativeValue()).doesNotThrowAnyException();819 }820 @Test821 void should_ignore_test_when_assumption_fails() {822 expectAssumptionNotMetException(() -> given(actual).hasNegativeValue());823 }824 }825 @Nested826 class BDDAssumptions_given_AtomicIntegerArray_Test {827 private final AtomicIntegerArray actual = new AtomicIntegerArray(0);828 @Test829 void should_run_test_when_assumption_passes() {830 thenCode(() -> given(actual).isEmpty()).doesNotThrowAnyException();831 }832 @Test833 void should_ignore_test_when_assumption_fails() {834 expectAssumptionNotMetException(() -> given(actual).isNotEmpty());835 }836 }837 @Nested838 class BDDAssumptions_given_AtomicIntegerFieldUpdater_Test {839 private class Yoda {840 @SuppressWarnings("unused")841 public volatile int field = 0;842 }843 private final AtomicIntegerFieldUpdater<Yoda> actual = AtomicIntegerFieldUpdater.newUpdater(Yoda.class, "field");844 private final Yoda value = new Yoda();845 @BeforeEach846 void beforeEach() {847 actual.set(value, 1);848 }849 @Test850 void should_run_test_when_assumption_passes() {851 thenCode(() -> given(actual).hasValue(1, value)).doesNotThrowAnyException();852 }853 @Test854 void should_ignore_test_when_assumption_fails() {855 expectAssumptionNotMetException(() -> given(actual).hasValue(2, value));856 }857 }...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!