1/*******************************************************************************
2 * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 *    Marc R. Hoffmann - initial API and implementation
10 *
11 *******************************************************************************/
12package org.jacoco.cli.internal.commands;
13
14import org.jacoco.cli.internal.CommandTestBase;
15import org.junit.Test;
16
17/**
18 * Unit tests for {@link ClassInfo}.
19 */
20public class ClassInfoTest extends CommandTestBase {
21
22	@Test
23	public void should_print_usage_when_invalid_option_is_given()
24			throws Exception {
25		execute("classinfo", "--invalid");
26
27		assertFailure();
28		assertContains("\"--invalid\" is not a valid option", err);
29		assertContains(
30				"java -jar jacococli.jar classinfo [<classlocations> ...]",
31				err);
32	}
33
34	@Test
35	public void should_print_warning_when_no_class_files_are_provided()
36			throws Exception {
37		execute("classinfo");
38
39		assertOk();
40		assertContains("[WARN] No class files provided.", out);
41	}
42
43	@Test
44	public void should_print_class_info() throws Exception {
45		execute("classinfo", getClassPath());
46
47		assertOk();
48		assertContains("class", out);
49		assertContains("org/jacoco/cli/internal/commands/ClassInfoTest", out);
50		assertContainsNot("method", out);
51	}
52
53	@Test
54	public void should_print_class_details_when_verbose() throws Exception {
55		execute("classinfo", "--verbose", getClassPath());
56
57		assertOk();
58		assertContains("line", out);
59		assertContains("method", out);
60		assertContains("line", out);
61	}
62
63}
64